openjpeg_ffi 0.1.1 copy "openjpeg_ffi: ^0.1.1" to clipboard
openjpeg_ffi: ^0.1.1 copied to clipboard

Dart FFI bindings to OpenJPEG for decoding raw JPEG2000 codestreams, built via native-assets — no manual native setup required.

example/lib/main.dart

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:openjpeg_ffi/openjpeg_ffi.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final String resultText;

  @override
  void initState() {
    super.initState();
    // No bundled .j2k fixture in this minimal example — this just proves
    // the native call reaches OpenJPEG and a real decode error comes back,
    // which is enough to confirm the FFI wiring itself works end to end.
    // See ../test/openjpeg_ffi_test.dart for a real decode against a real
    // JPEG2000 tile.
    try {
      final image = decodeJ2k(Uint8List(0));
      resultText = 'decoded ${image.width}x${image.height}';
    } on Jp2kDecodeException catch (e) {
      resultText =
          'native call reached OpenJPEG, got the expected decode error:\n${e.message}';
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('openjpeg_ffi')),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(24),
            child: Text(
              resultText,
              style: const TextStyle(fontSize: 18),
              textAlign: TextAlign.center,
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
503
downloads

Publisher

verified publishermonlycute.id.vn

Weekly Downloads

Dart FFI bindings to OpenJPEG for decoding raw JPEG2000 codestreams, built via native-assets — no manual native setup required.

Repository (GitHub)
View/report issues

Topics

#ffi #jpeg2000 #image #codec

License

unknown (license)

Dependencies

code_assets, ffi, hooks, logging, native_toolchain_c

More

Packages that depend on openjpeg_ffi