From 8f102fd24e6693421d9d6ce7c2ded455940a9620 Mon Sep 17 00:00:00 2001 From: Koji Wakamiya Date: Mon, 8 Dec 2025 10:24:44 +0900 Subject: [PATCH 1/3] feat: Add ImageConverter.convert --- android/.gitignore | 9 - android/build.gradle | 63 - android/settings.gradle | 1 - android/src/main/AndroidManifest.xml | 3 - ffigen.dart | 31 + ffigen.yaml | 19 - ios/Classes/image_ffi.c | 3 - ios/image_ffi.podspec | 28 - jnigen.yaml | 17 + lib/gen/darwin_bindings.dart | 105 + lib/gen/jnigen_bindings.dart | 4677 +++++++++++++++++ lib/image_ffi.dart | 226 +- lib/image_ffi_bindings_generated.dart | 69 - lib/src/image_converter_android.dart | 93 + lib/src/image_converter_darwin.dart | 112 + .../image_converter_platform_interface.dart | 36 + lib/src/output_format.dart | 32 + pubspec.yaml | 22 +- src/CMakeLists.txt | 22 - src/image_ffi.c | 23 - src/image_ffi.h | 30 - 21 files changed, 5219 insertions(+), 402 deletions(-) delete mode 100644 android/.gitignore delete mode 100644 android/build.gradle delete mode 100644 android/settings.gradle delete mode 100644 android/src/main/AndroidManifest.xml create mode 100644 ffigen.dart delete mode 100644 ffigen.yaml delete mode 100644 ios/Classes/image_ffi.c delete mode 100644 ios/image_ffi.podspec create mode 100644 jnigen.yaml create mode 100644 lib/gen/darwin_bindings.dart create mode 100644 lib/gen/jnigen_bindings.dart delete mode 100644 lib/image_ffi_bindings_generated.dart create mode 100644 lib/src/image_converter_android.dart create mode 100644 lib/src/image_converter_darwin.dart create mode 100644 lib/src/image_converter_platform_interface.dart create mode 100644 lib/src/output_format.dart delete mode 100644 src/CMakeLists.txt delete mode 100644 src/image_ffi.c delete mode 100644 src/image_ffi.h diff --git a/android/.gitignore b/android/.gitignore deleted file mode 100644 index 161bdcd..0000000 --- a/android/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -.cxx diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index cc50e66..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,63 +0,0 @@ -// The Android Gradle Plugin builds the native code with the Android NDK. - -group = "dr1009.com.image_ffi" -version = "1.0" - -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - // The Android Gradle Plugin knows how to build native code with the NDK. - classpath("com.android.tools.build:gradle:8.11.1") - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: "com.android.library" - -android { - namespace = "dr1009.com.image_ffi" - - // Bumping the plugin compileSdk version requires all clients of this plugin - // to bump the version in their app. - compileSdk = 36 - - // Use the NDK version - // declared in /android/app/build.gradle file of the Flutter project. - // Replace it with a version number if this plugin requires a specific NDK version. - // (e.g. ndkVersion "23.1.7779620") - ndkVersion = android.ndkVersion - - // Invoke the shared CMake build with the Android Gradle Plugin. - externalNativeBuild { - cmake { - path = "../src/CMakeLists.txt" - - // The default CMake version for the Android Gradle Plugin is 3.10.2. - // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake - // - // The Flutter tooling requires that developers have CMake 3.10 or later - // installed. You should not increase this version, as doing so will cause - // the plugin to fail to compile for some customers of the plugin. - // version "3.10.2" - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - defaultConfig { - minSdk = 24 - } -} diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index 5397af8..0000000 --- a/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'image_ffi' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index f52894f..0000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/ffigen.dart b/ffigen.dart new file mode 100644 index 0000000..626a98a --- /dev/null +++ b/ffigen.dart @@ -0,0 +1,31 @@ +// Regenerate bindings with `dart run ffigen.dart`. +import 'package:ffigen/ffigen.dart'; + +final config = FfiGenerator( + headers: Headers( + entryPoints: [ + Uri.file( + '$macSdkPath/System/Library/Frameworks/ImageIO.framework/Headers/ImageIO.h', + ), + ], + ), + objectiveC: ObjectiveC(interfaces: Interfaces.includeSet({'ImageIO'})), + output: Output(dartFile: Uri.file('lib/gen/darwin_bindings.dart')), + functions: Functions.includeSet({ + // CFData operations + 'CFDataCreate', + 'CFDataCreateMutable', + 'CFDataGetBytePtr', + 'CFDataGetLength', + // CGImageSource operations (decoding) + 'CGImageSourceCreateWithData', + 'CGImageSourceCreateImageAtIndex', + // CGImageDestination operations (encoding) + 'CGImageDestinationCreateWithData', + 'CGImageDestinationAddImage', + 'CGImageDestinationFinalize', + }), + globals: Globals.includeSet({'kCFAllocatorDefault'}), +); + +void main() => config.generate(); diff --git a/ffigen.yaml b/ffigen.yaml deleted file mode 100644 index e2992de..0000000 --- a/ffigen.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Run with `dart run ffigen --config ffigen.yaml`. -name: ImageFfiBindings -description: | - Bindings for `src/image_ffi.h`. - - Regenerate bindings with `dart run ffigen --config ffigen.yaml`. -output: 'lib/image_ffi_bindings_generated.dart' -headers: - entry-points: - - 'src/image_ffi.h' - include-directives: - - 'src/image_ffi.h' -preamble: | - // ignore_for_file: always_specify_types - // ignore_for_file: camel_case_types - // ignore_for_file: non_constant_identifier_names -comments: - style: any - length: full diff --git a/ios/Classes/image_ffi.c b/ios/Classes/image_ffi.c deleted file mode 100644 index 8f5b39b..0000000 --- a/ios/Classes/image_ffi.c +++ /dev/null @@ -1,3 +0,0 @@ -// Relative import to be able to reuse the C sources. -// See the comment in ../image_ffi.podspec for more information. -#include "../../src/image_ffi.c" diff --git a/ios/image_ffi.podspec b/ios/image_ffi.podspec deleted file mode 100644 index 8b68a00..0000000 --- a/ios/image_ffi.podspec +++ /dev/null @@ -1,28 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint image_ffi.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'image_ffi' - s.version = '0.0.1' - s.summary = 'A new Flutter FFI plugin project.' - s.description = <<-DESC -A new Flutter FFI plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'Flutter' - s.platform = :ios, '13.0' - - # Flutter.framework does not contain a i386 slice. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } - s.swift_version = '5.0' -end diff --git a/jnigen.yaml b/jnigen.yaml new file mode 100644 index 0000000..562c203 --- /dev/null +++ b/jnigen.yaml @@ -0,0 +1,17 @@ +# Regenerate bindings with `dart run jnigen --config jnigen.yaml`. + +android_sdk_config: + add_gradle_deps: true + android_example: 'example/' + +output: + dart: + path: lib/gen/jnigen_bindings.dart + structure: single_file + +source_path: + - 'java/' +classes: + - 'java.io.ByteArrayOutputStream' + - 'android/graphics/BitmapFactory' + - 'android/graphics/Bitmap' diff --git a/lib/gen/darwin_bindings.dart b/lib/gen/darwin_bindings.dart new file mode 100644 index 0000000..2866e3c --- /dev/null +++ b/lib/gen/darwin_bindings.dart @@ -0,0 +1,105 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint, unused_import +import 'dart:ffi' as ffi; +import 'package:objective_c/objective_c.dart' as objc; + +@ffi.Native>() +external final ffi.Pointer<__CFAllocator> kCFAllocatorDefault; + +@ffi.Native< + ffi.Pointer<__CFData> Function( + ffi.Pointer<__CFAllocator>, + ffi.Pointer, + ffi.Long, + ) +>() +external ffi.Pointer<__CFData> CFDataCreate( + ffi.Pointer<__CFAllocator> allocator, + ffi.Pointer bytes, + int length, +); + +@ffi.Native< + ffi.Pointer<__CFData> Function(ffi.Pointer<__CFAllocator>, ffi.Long) +>() +external ffi.Pointer<__CFData> CFDataCreateMutable( + ffi.Pointer<__CFAllocator> allocator, + int capacity, +); + +@ffi.Native)>() +external int CFDataGetLength(ffi.Pointer<__CFData> theData); + +@ffi.Native Function(ffi.Pointer<__CFData>)>() +external ffi.Pointer CFDataGetBytePtr( + ffi.Pointer<__CFData> theData, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer<__CFData>, + ffi.Pointer<__CFDictionary>, + ) +>() +external ffi.Pointer CGImageSourceCreateWithData( + ffi.Pointer<__CFData> data, + ffi.Pointer<__CFDictionary> options, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Size, + ffi.Pointer<__CFDictionary>, + ) +>() +external ffi.Pointer CGImageSourceCreateImageAtIndex( + ffi.Pointer isrc, + int index, + ffi.Pointer<__CFDictionary> options, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer<__CFData>, + ffi.Pointer, + ffi.Size, + ffi.Pointer<__CFDictionary>, + ) +>() +external ffi.Pointer CGImageDestinationCreateWithData( + ffi.Pointer<__CFData> data, + ffi.Pointer type, + int count, + ffi.Pointer<__CFDictionary> options, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer<__CFDictionary>, + ) +>() +external void CGImageDestinationAddImage( + ffi.Pointer idst, + ffi.Pointer image, + ffi.Pointer<__CFDictionary> properties, +); + +@ffi.Native)>() +external bool CGImageDestinationFinalize(ffi.Pointer idst); + +final class __CFAllocator extends ffi.Opaque {} + +final class __CFDictionary extends ffi.Opaque {} + +final class __CFData extends ffi.Opaque {} + +final class CGImageSource extends ffi.Opaque {} + +final class CGImage extends ffi.Opaque {} + +final class CGImageDestination extends ffi.Opaque {} diff --git a/lib/gen/jnigen_bindings.dart b/lib/gen/jnigen_bindings.dart new file mode 100644 index 0000000..f419ec9 --- /dev/null +++ b/lib/gen/jnigen_bindings.dart @@ -0,0 +1,4677 @@ +// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: argument_type_not_assignable +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: comment_references +// ignore_for_file: doc_directive_unknown +// ignore_for_file: file_names +// ignore_for_file: inference_failure_on_untyped_parameter +// ignore_for_file: invalid_internal_annotation +// ignore_for_file: invalid_use_of_internal_member +// ignore_for_file: library_prefixes +// ignore_for_file: lines_longer_than_80_chars +// ignore_for_file: no_leading_underscores_for_library_prefixes +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: only_throw_errors +// ignore_for_file: overridden_fields +// ignore_for_file: prefer_double_quotes +// ignore_for_file: unintended_html_in_doc_comment +// ignore_for_file: unnecessary_cast +// ignore_for_file: unnecessary_non_null_assertion +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_local_variable +// ignore_for_file: unused_shown_name +// ignore_for_file: use_super_parameters + +import 'dart:core' as core$_; +import 'dart:core' show Object, String, bool, double, int; + +import 'package:jni/_internal.dart' as jni$_; +import 'package:jni/jni.dart' as jni$_; + +/// from: `java.io.ByteArrayOutputStream` +class ByteArrayOutputStream extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JType $type; + + @jni$_.internal + ByteArrayOutputStream.fromReference(jni$_.JReference reference) + : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'java/io/ByteArrayOutputStream'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType nullableType = + $ByteArrayOutputStream$NullableType$(); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $ByteArrayOutputStream$Type$(); + static final _id_new$ = _class.constructorId(r'()V'); + + static final _new$ = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory ByteArrayOutputStream() { + return ByteArrayOutputStream.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr).reference, + ); + } + + static final _id_new$1 = _class.constructorId(r'(I)V'); + + static final _new$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void (int i)` + /// The returned object must be released after use, by calling the [release] method. + factory ByteArrayOutputStream.new$1(int i) { + return ByteArrayOutputStream.fromReference( + _new$1( + _class.reference.pointer, + _id_new$1 as jni$_.JMethodIDPtr, + i, + ).reference, + ); + } + + static final _id_close = _class.instanceMethodId(r'close', r'()V'); + + static final _close = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void close()` + void close() { + _close(reference.pointer, _id_close as jni$_.JMethodIDPtr).check(); + } + + static final _id_reset = _class.instanceMethodId(r'reset', r'()V'); + + static final _reset = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void reset()` + void reset() { + _reset(reference.pointer, _id_reset as jni$_.JMethodIDPtr).check(); + } + + static final _id_size = _class.instanceMethodId(r'size', r'()I'); + + static final _size = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int size()` + int size() { + return _size(reference.pointer, _id_size as jni$_.JMethodIDPtr).integer; + } + + static final _id_toByteArray = _class.instanceMethodId( + r'toByteArray', + r'()[B', + ); + + static final _toByteArray = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public byte[] toByteArray()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JByteArray? toByteArray() { + return _toByteArray( + reference.pointer, + _id_toByteArray as jni$_.JMethodIDPtr, + ).object(const jni$_.$JByteArray$NullableType$()); + } + + static final _id_toString$1 = _class.instanceMethodId( + r'toString', + r'()Ljava/lang/String;', + ); + + static final _toString$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public java.lang.String toString()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? toString$1() { + return _toString$1( + reference.pointer, + _id_toString$1 as jni$_.JMethodIDPtr, + ).object(const jni$_.$JString$NullableType$()); + } + + static final _id_toString$2 = _class.instanceMethodId( + r'toString', + r'(I)Ljava/lang/String;', + ); + + static final _toString$2 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public java.lang.String toString(int i)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? toString$2(int i) { + return _toString$2( + reference.pointer, + _id_toString$2 as jni$_.JMethodIDPtr, + i, + ).object(const jni$_.$JString$NullableType$()); + } + + static final _id_toString$3 = _class.instanceMethodId( + r'toString', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _toString$3 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public java.lang.String toString(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? toString$3(jni$_.JString? string) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _toString$3( + reference.pointer, + _id_toString$3 as jni$_.JMethodIDPtr, + _$string.pointer, + ).object(const jni$_.$JString$NullableType$()); + } + + static final _id_toString$4 = _class.instanceMethodId( + r'toString', + r'(Ljava/nio/charset/Charset;)Ljava/lang/String;', + ); + + static final _toString$4 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public java.lang.String toString(java.nio.charset.Charset charset)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? toString$4(jni$_.JObject? charset) { + final _$charset = charset?.reference ?? jni$_.jNullReference; + return _toString$4( + reference.pointer, + _id_toString$4 as jni$_.JMethodIDPtr, + _$charset.pointer, + ).object(const jni$_.$JString$NullableType$()); + } + + static final _id_write = _class.instanceMethodId(r'write', r'([BII)V'); + + static final _write = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Pointer, jni$_.Int32, jni$_.Int32) + >, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + ) + >(); + + /// from: `public void write(byte[] bs, int i, int i1)` + void write(jni$_.JByteArray? bs, int i, int i1) { + final _$bs = bs?.reference ?? jni$_.jNullReference; + _write( + reference.pointer, + _id_write as jni$_.JMethodIDPtr, + _$bs.pointer, + i, + i1, + ).check(); + } + + static final _id_write$1 = _class.instanceMethodId(r'write', r'(I)V'); + + static final _write$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void write(int i)` + void write$1(int i) { + _write$1(reference.pointer, _id_write$1 as jni$_.JMethodIDPtr, i).check(); + } + + static final _id_writeBytes = _class.instanceMethodId( + r'writeBytes', + r'([B)V', + ); + + static final _writeBytes = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void writeBytes(byte[] bs)` + void writeBytes(jni$_.JByteArray? bs) { + final _$bs = bs?.reference ?? jni$_.jNullReference; + _writeBytes( + reference.pointer, + _id_writeBytes as jni$_.JMethodIDPtr, + _$bs.pointer, + ).check(); + } + + static final _id_writeTo = _class.instanceMethodId( + r'writeTo', + r'(Ljava/io/OutputStream;)V', + ); + + static final _writeTo = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void writeTo(java.io.OutputStream outputStream)` + void writeTo(jni$_.JObject? outputStream) { + final _$outputStream = outputStream?.reference ?? jni$_.jNullReference; + _writeTo( + reference.pointer, + _id_writeTo as jni$_.JMethodIDPtr, + _$outputStream.pointer, + ).check(); + } +} + +final class $ByteArrayOutputStream$NullableType$ + extends jni$_.JType { + @jni$_.internal + const $ByteArrayOutputStream$NullableType$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/io/ByteArrayOutputStream;'; + + @jni$_.internal + @core$_.override + ByteArrayOutputStream? fromReference(jni$_.JReference reference) => + reference.isNull ? null : ByteArrayOutputStream.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($ByteArrayOutputStream$NullableType$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($ByteArrayOutputStream$NullableType$) && + other is $ByteArrayOutputStream$NullableType$; + } +} + +final class $ByteArrayOutputStream$Type$ + extends jni$_.JType { + @jni$_.internal + const $ByteArrayOutputStream$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/io/ByteArrayOutputStream;'; + + @jni$_.internal + @core$_.override + ByteArrayOutputStream fromReference(jni$_.JReference reference) => + ByteArrayOutputStream.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => + const $ByteArrayOutputStream$NullableType$(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($ByteArrayOutputStream$Type$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($ByteArrayOutputStream$Type$) && + other is $ByteArrayOutputStream$Type$; + } +} + +/// from: `android.graphics.BitmapFactory$Options` +class BitmapFactory$Options extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JType $type; + + @jni$_.internal + BitmapFactory$Options.fromReference(jni$_.JReference reference) + : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName( + r'android/graphics/BitmapFactory$Options', + ); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType nullableType = + $BitmapFactory$Options$NullableType$(); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $BitmapFactory$Options$Type$(); + static final _id_inBitmap = _class.instanceFieldId( + r'inBitmap', + r'Landroid/graphics/Bitmap;', + ); + + /// from: `public android.graphics.Bitmap inBitmap` + /// The returned object must be released after use, by calling the [release] method. + Bitmap? get inBitmap => _id_inBitmap.get(this, const $Bitmap$NullableType$()); + + /// from: `public android.graphics.Bitmap inBitmap` + /// The returned object must be released after use, by calling the [release] method. + set inBitmap(Bitmap? value) => + _id_inBitmap.set(this, const $Bitmap$NullableType$(), value); + + static final _id_inDensity = _class.instanceFieldId(r'inDensity', r'I'); + + /// from: `public int inDensity` + int get inDensity => _id_inDensity.get(this, const jni$_.jintType()); + + /// from: `public int inDensity` + set inDensity(int value) => + _id_inDensity.set(this, const jni$_.jintType(), value); + + static final _id_inDither = _class.instanceFieldId(r'inDither', r'Z'); + + /// from: `public boolean inDither` + bool get inDither => _id_inDither.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inDither` + set inDither(bool value) => + _id_inDither.set(this, const jni$_.jbooleanType(), value); + + static final _id_inInputShareable = _class.instanceFieldId( + r'inInputShareable', + r'Z', + ); + + /// from: `public boolean inInputShareable` + bool get inInputShareable => + _id_inInputShareable.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inInputShareable` + set inInputShareable(bool value) => + _id_inInputShareable.set(this, const jni$_.jbooleanType(), value); + + static final _id_inJustDecodeBounds = _class.instanceFieldId( + r'inJustDecodeBounds', + r'Z', + ); + + /// from: `public boolean inJustDecodeBounds` + bool get inJustDecodeBounds => + _id_inJustDecodeBounds.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inJustDecodeBounds` + set inJustDecodeBounds(bool value) => + _id_inJustDecodeBounds.set(this, const jni$_.jbooleanType(), value); + + static final _id_inMutable = _class.instanceFieldId(r'inMutable', r'Z'); + + /// from: `public boolean inMutable` + bool get inMutable => _id_inMutable.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inMutable` + set inMutable(bool value) => + _id_inMutable.set(this, const jni$_.jbooleanType(), value); + + static final _id_inPreferQualityOverSpeed = _class.instanceFieldId( + r'inPreferQualityOverSpeed', + r'Z', + ); + + /// from: `public boolean inPreferQualityOverSpeed` + bool get inPreferQualityOverSpeed => + _id_inPreferQualityOverSpeed.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inPreferQualityOverSpeed` + set inPreferQualityOverSpeed(bool value) => + _id_inPreferQualityOverSpeed.set(this, const jni$_.jbooleanType(), value); + + static final _id_inPreferredColorSpace = _class.instanceFieldId( + r'inPreferredColorSpace', + r'Landroid/graphics/ColorSpace;', + ); + + /// from: `public android.graphics.ColorSpace inPreferredColorSpace` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? get inPreferredColorSpace => + _id_inPreferredColorSpace.get(this, const jni$_.$JObject$NullableType$()); + + /// from: `public android.graphics.ColorSpace inPreferredColorSpace` + /// The returned object must be released after use, by calling the [release] method. + set inPreferredColorSpace(jni$_.JObject? value) => _id_inPreferredColorSpace + .set(this, const jni$_.$JObject$NullableType$(), value); + + static final _id_inPreferredConfig = _class.instanceFieldId( + r'inPreferredConfig', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `public android.graphics.Bitmap$Config inPreferredConfig` + /// The returned object must be released after use, by calling the [release] method. + Bitmap$Config? get inPreferredConfig => + _id_inPreferredConfig.get(this, const $Bitmap$Config$NullableType$()); + + /// from: `public android.graphics.Bitmap$Config inPreferredConfig` + /// The returned object must be released after use, by calling the [release] method. + set inPreferredConfig(Bitmap$Config? value) => _id_inPreferredConfig.set( + this, + const $Bitmap$Config$NullableType$(), + value, + ); + + static final _id_inPremultiplied = _class.instanceFieldId( + r'inPremultiplied', + r'Z', + ); + + /// from: `public boolean inPremultiplied` + bool get inPremultiplied => + _id_inPremultiplied.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inPremultiplied` + set inPremultiplied(bool value) => + _id_inPremultiplied.set(this, const jni$_.jbooleanType(), value); + + static final _id_inPurgeable = _class.instanceFieldId(r'inPurgeable', r'Z'); + + /// from: `public boolean inPurgeable` + bool get inPurgeable => _id_inPurgeable.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inPurgeable` + set inPurgeable(bool value) => + _id_inPurgeable.set(this, const jni$_.jbooleanType(), value); + + static final _id_inSampleSize = _class.instanceFieldId(r'inSampleSize', r'I'); + + /// from: `public int inSampleSize` + int get inSampleSize => _id_inSampleSize.get(this, const jni$_.jintType()); + + /// from: `public int inSampleSize` + set inSampleSize(int value) => + _id_inSampleSize.set(this, const jni$_.jintType(), value); + + static final _id_inScaled = _class.instanceFieldId(r'inScaled', r'Z'); + + /// from: `public boolean inScaled` + bool get inScaled => _id_inScaled.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean inScaled` + set inScaled(bool value) => + _id_inScaled.set(this, const jni$_.jbooleanType(), value); + + static final _id_inScreenDensity = _class.instanceFieldId( + r'inScreenDensity', + r'I', + ); + + /// from: `public int inScreenDensity` + int get inScreenDensity => + _id_inScreenDensity.get(this, const jni$_.jintType()); + + /// from: `public int inScreenDensity` + set inScreenDensity(int value) => + _id_inScreenDensity.set(this, const jni$_.jintType(), value); + + static final _id_inTargetDensity = _class.instanceFieldId( + r'inTargetDensity', + r'I', + ); + + /// from: `public int inTargetDensity` + int get inTargetDensity => + _id_inTargetDensity.get(this, const jni$_.jintType()); + + /// from: `public int inTargetDensity` + set inTargetDensity(int value) => + _id_inTargetDensity.set(this, const jni$_.jintType(), value); + + static final _id_inTempStorage = _class.instanceFieldId( + r'inTempStorage', + r'[B', + ); + + /// from: `public byte[] inTempStorage` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JByteArray? get inTempStorage => + _id_inTempStorage.get(this, const jni$_.$JByteArray$NullableType$()); + + /// from: `public byte[] inTempStorage` + /// The returned object must be released after use, by calling the [release] method. + set inTempStorage(jni$_.JByteArray? value) => _id_inTempStorage.set( + this, + const jni$_.$JByteArray$NullableType$(), + value, + ); + + static final _id_mCancel = _class.instanceFieldId(r'mCancel', r'Z'); + + /// from: `public boolean mCancel` + bool get mCancel => _id_mCancel.get(this, const jni$_.jbooleanType()); + + /// from: `public boolean mCancel` + set mCancel(bool value) => + _id_mCancel.set(this, const jni$_.jbooleanType(), value); + + static final _id_outColorSpace = _class.instanceFieldId( + r'outColorSpace', + r'Landroid/graphics/ColorSpace;', + ); + + /// from: `public android.graphics.ColorSpace outColorSpace` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? get outColorSpace => + _id_outColorSpace.get(this, const jni$_.$JObject$NullableType$()); + + /// from: `public android.graphics.ColorSpace outColorSpace` + /// The returned object must be released after use, by calling the [release] method. + set outColorSpace(jni$_.JObject? value) => + _id_outColorSpace.set(this, const jni$_.$JObject$NullableType$(), value); + + static final _id_outConfig = _class.instanceFieldId( + r'outConfig', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `public android.graphics.Bitmap$Config outConfig` + /// The returned object must be released after use, by calling the [release] method. + Bitmap$Config? get outConfig => + _id_outConfig.get(this, const $Bitmap$Config$NullableType$()); + + /// from: `public android.graphics.Bitmap$Config outConfig` + /// The returned object must be released after use, by calling the [release] method. + set outConfig(Bitmap$Config? value) => + _id_outConfig.set(this, const $Bitmap$Config$NullableType$(), value); + + static final _id_outHeight = _class.instanceFieldId(r'outHeight', r'I'); + + /// from: `public int outHeight` + int get outHeight => _id_outHeight.get(this, const jni$_.jintType()); + + /// from: `public int outHeight` + set outHeight(int value) => + _id_outHeight.set(this, const jni$_.jintType(), value); + + static final _id_outMimeType = _class.instanceFieldId( + r'outMimeType', + r'Ljava/lang/String;', + ); + + /// from: `public java.lang.String outMimeType` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? get outMimeType => + _id_outMimeType.get(this, const jni$_.$JString$NullableType$()); + + /// from: `public java.lang.String outMimeType` + /// The returned object must be released after use, by calling the [release] method. + set outMimeType(jni$_.JString? value) => + _id_outMimeType.set(this, const jni$_.$JString$NullableType$(), value); + + static final _id_outWidth = _class.instanceFieldId(r'outWidth', r'I'); + + /// from: `public int outWidth` + int get outWidth => _id_outWidth.get(this, const jni$_.jintType()); + + /// from: `public int outWidth` + set outWidth(int value) => + _id_outWidth.set(this, const jni$_.jintType(), value); + + static final _id_new$ = _class.constructorId(r'()V'); + + static final _new$ = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory BitmapFactory$Options() { + return BitmapFactory$Options.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr).reference, + ); + } + + static final _id_requestCancelDecode = _class.instanceMethodId( + r'requestCancelDecode', + r'()V', + ); + + static final _requestCancelDecode = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void requestCancelDecode()` + void requestCancelDecode() { + _requestCancelDecode( + reference.pointer, + _id_requestCancelDecode as jni$_.JMethodIDPtr, + ).check(); + } +} + +final class $BitmapFactory$Options$NullableType$ + extends jni$_.JType { + @jni$_.internal + const $BitmapFactory$Options$NullableType$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/BitmapFactory$Options;'; + + @jni$_.internal + @core$_.override + BitmapFactory$Options? fromReference(jni$_.JReference reference) => + reference.isNull ? null : BitmapFactory$Options.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($BitmapFactory$Options$NullableType$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($BitmapFactory$Options$NullableType$) && + other is $BitmapFactory$Options$NullableType$; + } +} + +final class $BitmapFactory$Options$Type$ + extends jni$_.JType { + @jni$_.internal + const $BitmapFactory$Options$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/BitmapFactory$Options;'; + + @jni$_.internal + @core$_.override + BitmapFactory$Options fromReference(jni$_.JReference reference) => + BitmapFactory$Options.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => + const $BitmapFactory$Options$NullableType$(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($BitmapFactory$Options$Type$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($BitmapFactory$Options$Type$) && + other is $BitmapFactory$Options$Type$; + } +} + +/// from: `android.graphics.BitmapFactory` +class BitmapFactory extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JType $type; + + @jni$_.internal + BitmapFactory.fromReference(jni$_.JReference reference) + : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'android/graphics/BitmapFactory'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType nullableType = + $BitmapFactory$NullableType$(); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $BitmapFactory$Type$(); + static final _id_new$ = _class.constructorId(r'()V'); + + static final _new$ = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory BitmapFactory() { + return BitmapFactory.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr).reference, + ); + } + + static final _id_decodeByteArray = _class.staticMethodId( + r'decodeByteArray', + r'([BII)Landroid/graphics/Bitmap;', + ); + + static final _decodeByteArray = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Pointer, jni$_.Int32, jni$_.Int32) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeByteArray(byte[] bs, int i, int i1)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeByteArray(jni$_.JByteArray? bs, int i, int i1) { + final _$bs = bs?.reference ?? jni$_.jNullReference; + return _decodeByteArray( + _class.reference.pointer, + _id_decodeByteArray as jni$_.JMethodIDPtr, + _$bs.pointer, + i, + i1, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeByteArray$1 = _class.staticMethodId( + r'decodeByteArray', + r'([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;', + ); + + static final _decodeByteArray$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeByteArray(byte[] bs, int i, int i1, android.graphics.BitmapFactory$Options options)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeByteArray$1( + jni$_.JByteArray? bs, + int i, + int i1, + BitmapFactory$Options? options, + ) { + final _$bs = bs?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + return _decodeByteArray$1( + _class.reference.pointer, + _id_decodeByteArray$1 as jni$_.JMethodIDPtr, + _$bs.pointer, + i, + i1, + _$options.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeFile = _class.staticMethodId( + r'decodeFile', + r'(Ljava/lang/String;)Landroid/graphics/Bitmap;', + ); + + static final _decodeFile = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeFile(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeFile(jni$_.JString? string) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _decodeFile( + _class.reference.pointer, + _id_decodeFile as jni$_.JMethodIDPtr, + _$string.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeFile$1 = _class.staticMethodId( + r'decodeFile', + r'(Ljava/lang/String;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;', + ); + + static final _decodeFile$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Pointer, jni$_.Pointer) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeFile(java.lang.String string, android.graphics.BitmapFactory$Options options)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeFile$1( + jni$_.JString? string, + BitmapFactory$Options? options, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + return _decodeFile$1( + _class.reference.pointer, + _id_decodeFile$1 as jni$_.JMethodIDPtr, + _$string.pointer, + _$options.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeFileDescriptor = _class.staticMethodId( + r'decodeFileDescriptor', + r'(Ljava/io/FileDescriptor;)Landroid/graphics/Bitmap;', + ); + + static final _decodeFileDescriptor = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeFileDescriptor(java.io.FileDescriptor fileDescriptor)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeFileDescriptor(jni$_.JObject? fileDescriptor) { + final _$fileDescriptor = fileDescriptor?.reference ?? jni$_.jNullReference; + return _decodeFileDescriptor( + _class.reference.pointer, + _id_decodeFileDescriptor as jni$_.JMethodIDPtr, + _$fileDescriptor.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeFileDescriptor$1 = _class.staticMethodId( + r'decodeFileDescriptor', + r'(Ljava/io/FileDescriptor;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;', + ); + + static final _decodeFileDescriptor$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeFileDescriptor(java.io.FileDescriptor fileDescriptor, android.graphics.Rect rect, android.graphics.BitmapFactory$Options options)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeFileDescriptor$1( + jni$_.JObject? fileDescriptor, + jni$_.JObject? rect, + BitmapFactory$Options? options, + ) { + final _$fileDescriptor = fileDescriptor?.reference ?? jni$_.jNullReference; + final _$rect = rect?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + return _decodeFileDescriptor$1( + _class.reference.pointer, + _id_decodeFileDescriptor$1 as jni$_.JMethodIDPtr, + _$fileDescriptor.pointer, + _$rect.pointer, + _$options.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeResource = _class.staticMethodId( + r'decodeResource', + r'(Landroid/content/res/Resources;I)Landroid/graphics/Bitmap;', + ); + + static final _decodeResource = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer, jni$_.Int32)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeResource(android.content.res.Resources resources, int i)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeResource(jni$_.JObject? resources, int i) { + final _$resources = resources?.reference ?? jni$_.jNullReference; + return _decodeResource( + _class.reference.pointer, + _id_decodeResource as jni$_.JMethodIDPtr, + _$resources.pointer, + i, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeResource$1 = _class.staticMethodId( + r'decodeResource', + r'(Landroid/content/res/Resources;ILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;', + ); + + static final _decodeResource$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeResource(android.content.res.Resources resources, int i, android.graphics.BitmapFactory$Options options)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeResource$1( + jni$_.JObject? resources, + int i, + BitmapFactory$Options? options, + ) { + final _$resources = resources?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + return _decodeResource$1( + _class.reference.pointer, + _id_decodeResource$1 as jni$_.JMethodIDPtr, + _$resources.pointer, + i, + _$options.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeResourceStream = _class.staticMethodId( + r'decodeResourceStream', + r'(Landroid/content/res/Resources;Landroid/util/TypedValue;Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;', + ); + + static final _decodeResourceStream = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeResourceStream(android.content.res.Resources resources, android.util.TypedValue typedValue, java.io.InputStream inputStream, android.graphics.Rect rect, android.graphics.BitmapFactory$Options options)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeResourceStream( + jni$_.JObject? resources, + jni$_.JObject? typedValue, + jni$_.JObject? inputStream, + jni$_.JObject? rect, + BitmapFactory$Options? options, + ) { + final _$resources = resources?.reference ?? jni$_.jNullReference; + final _$typedValue = typedValue?.reference ?? jni$_.jNullReference; + final _$inputStream = inputStream?.reference ?? jni$_.jNullReference; + final _$rect = rect?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + return _decodeResourceStream( + _class.reference.pointer, + _id_decodeResourceStream as jni$_.JMethodIDPtr, + _$resources.pointer, + _$typedValue.pointer, + _$inputStream.pointer, + _$rect.pointer, + _$options.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeStream = _class.staticMethodId( + r'decodeStream', + r'(Ljava/io/InputStream;)Landroid/graphics/Bitmap;', + ); + + static final _decodeStream = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeStream(java.io.InputStream inputStream)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeStream(jni$_.JObject? inputStream) { + final _$inputStream = inputStream?.reference ?? jni$_.jNullReference; + return _decodeStream( + _class.reference.pointer, + _id_decodeStream as jni$_.JMethodIDPtr, + _$inputStream.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_decodeStream$1 = _class.staticMethodId( + r'decodeStream', + r'(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;', + ); + + static final _decodeStream$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap decodeStream(java.io.InputStream inputStream, android.graphics.Rect rect, android.graphics.BitmapFactory$Options options)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? decodeStream$1( + jni$_.JObject? inputStream, + jni$_.JObject? rect, + BitmapFactory$Options? options, + ) { + final _$inputStream = inputStream?.reference ?? jni$_.jNullReference; + final _$rect = rect?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + return _decodeStream$1( + _class.reference.pointer, + _id_decodeStream$1 as jni$_.JMethodIDPtr, + _$inputStream.pointer, + _$rect.pointer, + _$options.pointer, + ).object(const $Bitmap$NullableType$()); + } +} + +final class $BitmapFactory$NullableType$ extends jni$_.JType { + @jni$_.internal + const $BitmapFactory$NullableType$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/BitmapFactory;'; + + @jni$_.internal + @core$_.override + BitmapFactory? fromReference(jni$_.JReference reference) => + reference.isNull ? null : BitmapFactory.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($BitmapFactory$NullableType$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($BitmapFactory$NullableType$) && + other is $BitmapFactory$NullableType$; + } +} + +final class $BitmapFactory$Type$ extends jni$_.JType { + @jni$_.internal + const $BitmapFactory$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/BitmapFactory;'; + + @jni$_.internal + @core$_.override + BitmapFactory fromReference(jni$_.JReference reference) => + BitmapFactory.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => + const $BitmapFactory$NullableType$(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($BitmapFactory$Type$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($BitmapFactory$Type$) && + other is $BitmapFactory$Type$; + } +} + +/// from: `android.graphics.Bitmap$CompressFormat` +class Bitmap$CompressFormat extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JType $type; + + @jni$_.internal + Bitmap$CompressFormat.fromReference(jni$_.JReference reference) + : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName( + r'android/graphics/Bitmap$CompressFormat', + ); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType nullableType = + $Bitmap$CompressFormat$NullableType$(); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $Bitmap$CompressFormat$Type$(); + static final _id_JPEG = _class.staticFieldId( + r'JPEG', + r'Landroid/graphics/Bitmap$CompressFormat;', + ); + + /// from: `static public final android.graphics.Bitmap$CompressFormat JPEG` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$CompressFormat get JPEG => + _id_JPEG.get(_class, const $Bitmap$CompressFormat$Type$()); + + static final _id_PNG = _class.staticFieldId( + r'PNG', + r'Landroid/graphics/Bitmap$CompressFormat;', + ); + + /// from: `static public final android.graphics.Bitmap$CompressFormat PNG` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$CompressFormat get PNG => + _id_PNG.get(_class, const $Bitmap$CompressFormat$Type$()); + + static final _id_WEBP = _class.staticFieldId( + r'WEBP', + r'Landroid/graphics/Bitmap$CompressFormat;', + ); + + /// from: `static public final android.graphics.Bitmap$CompressFormat WEBP` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$CompressFormat get WEBP => + _id_WEBP.get(_class, const $Bitmap$CompressFormat$Type$()); + + static final _id_WEBP_LOSSLESS = _class.staticFieldId( + r'WEBP_LOSSLESS', + r'Landroid/graphics/Bitmap$CompressFormat;', + ); + + /// from: `static public final android.graphics.Bitmap$CompressFormat WEBP_LOSSLESS` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$CompressFormat get WEBP_LOSSLESS => + _id_WEBP_LOSSLESS.get(_class, const $Bitmap$CompressFormat$Type$()); + + static final _id_WEBP_LOSSY = _class.staticFieldId( + r'WEBP_LOSSY', + r'Landroid/graphics/Bitmap$CompressFormat;', + ); + + /// from: `static public final android.graphics.Bitmap$CompressFormat WEBP_LOSSY` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$CompressFormat get WEBP_LOSSY => + _id_WEBP_LOSSY.get(_class, const $Bitmap$CompressFormat$Type$()); + + static final _id_values = _class.staticMethodId( + r'values', + r'()[Landroid/graphics/Bitmap$CompressFormat;', + ); + + static final _values = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `static public android.graphics.Bitmap$CompressFormat[] values()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JArray? values() { + return _values( + _class.reference.pointer, + _id_values as jni$_.JMethodIDPtr, + ).object?>( + const jni$_.$JArray$NullableType$( + $Bitmap$CompressFormat$NullableType$(), + ), + ); + } + + static final _id_valueOf = _class.staticMethodId( + r'valueOf', + r'(Ljava/lang/String;)Landroid/graphics/Bitmap$CompressFormat;', + ); + + static final _valueOf = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap$CompressFormat valueOf(java.lang.String synthetic)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$CompressFormat? valueOf(jni$_.JString? synthetic) { + final _$synthetic = synthetic?.reference ?? jni$_.jNullReference; + return _valueOf( + _class.reference.pointer, + _id_valueOf as jni$_.JMethodIDPtr, + _$synthetic.pointer, + ).object( + const $Bitmap$CompressFormat$NullableType$(), + ); + } +} + +final class $Bitmap$CompressFormat$NullableType$ + extends jni$_.JType { + @jni$_.internal + const $Bitmap$CompressFormat$NullableType$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/Bitmap$CompressFormat;'; + + @jni$_.internal + @core$_.override + Bitmap$CompressFormat? fromReference(jni$_.JReference reference) => + reference.isNull ? null : Bitmap$CompressFormat.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($Bitmap$CompressFormat$NullableType$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($Bitmap$CompressFormat$NullableType$) && + other is $Bitmap$CompressFormat$NullableType$; + } +} + +final class $Bitmap$CompressFormat$Type$ + extends jni$_.JType { + @jni$_.internal + const $Bitmap$CompressFormat$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/Bitmap$CompressFormat;'; + + @jni$_.internal + @core$_.override + Bitmap$CompressFormat fromReference(jni$_.JReference reference) => + Bitmap$CompressFormat.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => + const $Bitmap$CompressFormat$NullableType$(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($Bitmap$CompressFormat$Type$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($Bitmap$CompressFormat$Type$) && + other is $Bitmap$CompressFormat$Type$; + } +} + +/// from: `android.graphics.Bitmap$Config` +class Bitmap$Config extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JType $type; + + @jni$_.internal + Bitmap$Config.fromReference(jni$_.JReference reference) + : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'android/graphics/Bitmap$Config'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType nullableType = + $Bitmap$Config$NullableType$(); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Bitmap$Config$Type$(); + static final _id_ALPHA_8 = _class.staticFieldId( + r'ALPHA_8', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config ALPHA_8` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get ALPHA_8 => + _id_ALPHA_8.get(_class, const $Bitmap$Config$Type$()); + + static final _id_ARGB_4444 = _class.staticFieldId( + r'ARGB_4444', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config ARGB_4444` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get ARGB_4444 => + _id_ARGB_4444.get(_class, const $Bitmap$Config$Type$()); + + static final _id_ARGB_8888 = _class.staticFieldId( + r'ARGB_8888', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config ARGB_8888` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get ARGB_8888 => + _id_ARGB_8888.get(_class, const $Bitmap$Config$Type$()); + + static final _id_HARDWARE = _class.staticFieldId( + r'HARDWARE', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config HARDWARE` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get HARDWARE => + _id_HARDWARE.get(_class, const $Bitmap$Config$Type$()); + + static final _id_RGBA_1010102 = _class.staticFieldId( + r'RGBA_1010102', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config RGBA_1010102` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get RGBA_1010102 => + _id_RGBA_1010102.get(_class, const $Bitmap$Config$Type$()); + + static final _id_RGBA_F16 = _class.staticFieldId( + r'RGBA_F16', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config RGBA_F16` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get RGBA_F16 => + _id_RGBA_F16.get(_class, const $Bitmap$Config$Type$()); + + static final _id_RGB_565 = _class.staticFieldId( + r'RGB_565', + r'Landroid/graphics/Bitmap$Config;', + ); + + /// from: `static public final android.graphics.Bitmap$Config RGB_565` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config get RGB_565 => + _id_RGB_565.get(_class, const $Bitmap$Config$Type$()); + + static final _id_values = _class.staticMethodId( + r'values', + r'()[Landroid/graphics/Bitmap$Config;', + ); + + static final _values = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `static public android.graphics.Bitmap$Config[] values()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JArray? values() { + return _values( + _class.reference.pointer, + _id_values as jni$_.JMethodIDPtr, + ).object?>( + const jni$_.$JArray$NullableType$( + $Bitmap$Config$NullableType$(), + ), + ); + } + + static final _id_valueOf = _class.staticMethodId( + r'valueOf', + r'(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;', + ); + + static final _valueOf = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap$Config valueOf(java.lang.String synthetic)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap$Config? valueOf(jni$_.JString? synthetic) { + final _$synthetic = synthetic?.reference ?? jni$_.jNullReference; + return _valueOf( + _class.reference.pointer, + _id_valueOf as jni$_.JMethodIDPtr, + _$synthetic.pointer, + ).object(const $Bitmap$Config$NullableType$()); + } +} + +final class $Bitmap$Config$NullableType$ extends jni$_.JType { + @jni$_.internal + const $Bitmap$Config$NullableType$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/Bitmap$Config;'; + + @jni$_.internal + @core$_.override + Bitmap$Config? fromReference(jni$_.JReference reference) => + reference.isNull ? null : Bitmap$Config.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($Bitmap$Config$NullableType$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($Bitmap$Config$NullableType$) && + other is $Bitmap$Config$NullableType$; + } +} + +final class $Bitmap$Config$Type$ extends jni$_.JType { + @jni$_.internal + const $Bitmap$Config$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/Bitmap$Config;'; + + @jni$_.internal + @core$_.override + Bitmap$Config fromReference(jni$_.JReference reference) => + Bitmap$Config.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => + const $Bitmap$Config$NullableType$(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($Bitmap$Config$Type$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($Bitmap$Config$Type$) && + other is $Bitmap$Config$Type$; + } +} + +/// from: `android.graphics.Bitmap` +class Bitmap extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JType $type; + + @jni$_.internal + Bitmap.fromReference(jni$_.JReference reference) + : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'android/graphics/Bitmap'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType nullableType = $Bitmap$NullableType$(); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Bitmap$Type$(); + static final _id_CREATOR = _class.staticFieldId( + r'CREATOR', + r'Landroid/os/Parcelable$Creator;', + ); + + /// from: `static public final android.os.Parcelable$Creator CREATOR` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JObject? get CREATOR => + _id_CREATOR.get(_class, const jni$_.$JObject$NullableType$()); + + /// from: `static public final int DENSITY_NONE` + static const DENSITY_NONE = 0; + static final _id_asShared = _class.instanceMethodId( + r'asShared', + r'()Landroid/graphics/Bitmap;', + ); + + static final _asShared = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public android.graphics.Bitmap asShared()` + /// The returned object must be released after use, by calling the [release] method. + Bitmap? asShared() { + return _asShared( + reference.pointer, + _id_asShared as jni$_.JMethodIDPtr, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_compress = _class.instanceMethodId( + r'compress', + r'(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z', + ); + + static final _compress = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + jni$_.Pointer, + ) + >(); + + /// from: `public boolean compress(android.graphics.Bitmap$CompressFormat compressFormat, int i, java.io.OutputStream outputStream)` + bool compress( + Bitmap$CompressFormat? compressFormat, + int i, + jni$_.JObject? outputStream, + ) { + final _$compressFormat = compressFormat?.reference ?? jni$_.jNullReference; + final _$outputStream = outputStream?.reference ?? jni$_.jNullReference; + return _compress( + reference.pointer, + _id_compress as jni$_.JMethodIDPtr, + _$compressFormat.pointer, + i, + _$outputStream.pointer, + ).boolean; + } + + static final _id_copy = _class.instanceMethodId( + r'copy', + r'(Landroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;', + ); + + static final _copy = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer, jni$_.Int32)>, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + ) + >(); + + /// from: `public android.graphics.Bitmap copy(android.graphics.Bitmap$Config config, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + Bitmap? copy(Bitmap$Config? config, bool z) { + final _$config = config?.reference ?? jni$_.jNullReference; + return _copy( + reference.pointer, + _id_copy as jni$_.JMethodIDPtr, + _$config.pointer, + z ? 1 : 0, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_copyPixelsFromBuffer = _class.instanceMethodId( + r'copyPixelsFromBuffer', + r'(Ljava/nio/Buffer;)V', + ); + + static final _copyPixelsFromBuffer = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void copyPixelsFromBuffer(java.nio.Buffer buffer)` + void copyPixelsFromBuffer(jni$_.JBuffer? buffer) { + final _$buffer = buffer?.reference ?? jni$_.jNullReference; + _copyPixelsFromBuffer( + reference.pointer, + _id_copyPixelsFromBuffer as jni$_.JMethodIDPtr, + _$buffer.pointer, + ).check(); + } + + static final _id_copyPixelsToBuffer = _class.instanceMethodId( + r'copyPixelsToBuffer', + r'(Ljava/nio/Buffer;)V', + ); + + static final _copyPixelsToBuffer = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void copyPixelsToBuffer(java.nio.Buffer buffer)` + void copyPixelsToBuffer(jni$_.JBuffer? buffer) { + final _$buffer = buffer?.reference ?? jni$_.jNullReference; + _copyPixelsToBuffer( + reference.pointer, + _id_copyPixelsToBuffer as jni$_.JMethodIDPtr, + _$buffer.pointer, + ).check(); + } + + static final _id_createBitmap = _class.staticMethodId( + r'createBitmap', + r'(Landroid/graphics/Bitmap;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.graphics.Bitmap bitmap)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap(Bitmap? bitmap) { + final _$bitmap = bitmap?.reference ?? jni$_.jNullReference; + return _createBitmap( + _class.reference.pointer, + _id_createBitmap as jni$_.JMethodIDPtr, + _$bitmap.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$1 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/graphics/Bitmap;IIII)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + int, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.graphics.Bitmap bitmap, int i, int i1, int i2, int i3)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$1(Bitmap? bitmap, int i, int i1, int i2, int i3) { + final _$bitmap = bitmap?.reference ?? jni$_.jNullReference; + return _createBitmap$1( + _class.reference.pointer, + _id_createBitmap$1 as jni$_.JMethodIDPtr, + _$bitmap.pointer, + i, + i1, + i2, + i3, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$2 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$2 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + int, + int, + jni$_.Pointer, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.graphics.Bitmap bitmap, int i, int i1, int i2, int i3, android.graphics.Matrix matrix, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$2( + Bitmap? bitmap, + int i, + int i1, + int i2, + int i3, + jni$_.JObject? matrix, + bool z, + ) { + final _$bitmap = bitmap?.reference ?? jni$_.jNullReference; + final _$matrix = matrix?.reference ?? jni$_.jNullReference; + return _createBitmap$2( + _class.reference.pointer, + _id_createBitmap$2 as jni$_.JMethodIDPtr, + _$bitmap.pointer, + i, + i1, + i2, + i3, + _$matrix.pointer, + z ? 1 : 0, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$3 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/graphics/Picture;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$3 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.graphics.Picture picture)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$3(jni$_.JObject? picture) { + final _$picture = picture?.reference ?? jni$_.jNullReference; + return _createBitmap$3( + _class.reference.pointer, + _id_createBitmap$3 as jni$_.JMethodIDPtr, + _$picture.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$4 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/graphics/Picture;IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$4 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.graphics.Picture picture, int i, int i1, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$4( + jni$_.JObject? picture, + int i, + int i1, + Bitmap$Config? config, + ) { + final _$picture = picture?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$4( + _class.reference.pointer, + _id_createBitmap$4 as jni$_.JMethodIDPtr, + _$picture.pointer, + i, + i1, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$5 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$5 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int i, int i1, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$5( + jni$_.JObject? displayMetrics, + int i, + int i1, + Bitmap$Config? config, + ) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$5( + _class.reference.pointer, + _id_createBitmap$5 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + i, + i1, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$6 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$6 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int i, int i1, android.graphics.Bitmap$Config config, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$6( + jni$_.JObject? displayMetrics, + int i, + int i1, + Bitmap$Config? config, + bool z, + ) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$6( + _class.reference.pointer, + _id_createBitmap$6 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + i, + i1, + _$config.pointer, + z ? 1 : 0, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$7 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/util/DisplayMetrics;IILandroid/graphics/Bitmap$Config;ZLandroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$7 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int i, int i1, android.graphics.Bitmap$Config config, boolean z, android.graphics.ColorSpace colorSpace)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$7( + jni$_.JObject? displayMetrics, + int i, + int i1, + Bitmap$Config? config, + bool z, + jni$_.JObject? colorSpace, + ) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + final _$colorSpace = colorSpace?.reference ?? jni$_.jNullReference; + return _createBitmap$7( + _class.reference.pointer, + _id_createBitmap$7 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + i, + i1, + _$config.pointer, + z ? 1 : 0, + _$colorSpace.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$8 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/util/DisplayMetrics;[IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$8 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int[] is, int i, int i1, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$8( + jni$_.JObject? displayMetrics, + jni$_.JIntArray? is$, + int i, + int i1, + Bitmap$Config? config, + ) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + final _$is$ = is$?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$8( + _class.reference.pointer, + _id_createBitmap$8 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + _$is$.pointer, + i, + i1, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$9 = _class.staticMethodId( + r'createBitmap', + r'(Landroid/util/DisplayMetrics;[IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$9 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + int, + int, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(android.util.DisplayMetrics displayMetrics, int[] is, int i, int i1, int i2, int i3, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$9( + jni$_.JObject? displayMetrics, + jni$_.JIntArray? is$, + int i, + int i1, + int i2, + int i3, + Bitmap$Config? config, + ) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + final _$is$ = is$?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$9( + _class.reference.pointer, + _id_createBitmap$9 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + _$is$.pointer, + i, + i1, + i2, + i3, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$10 = _class.staticMethodId( + r'createBitmap', + r'(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$10 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Int32, jni$_.Int32, jni$_.Pointer) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(int i, int i1, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$10(int i, int i1, Bitmap$Config? config) { + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$10( + _class.reference.pointer, + _id_createBitmap$10 as jni$_.JMethodIDPtr, + i, + i1, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$11 = _class.staticMethodId( + r'createBitmap', + r'(IILandroid/graphics/Bitmap$Config;Z)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$11 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + jni$_.Pointer, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(int i, int i1, android.graphics.Bitmap$Config config, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$11(int i, int i1, Bitmap$Config? config, bool z) { + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$11( + _class.reference.pointer, + _id_createBitmap$11 as jni$_.JMethodIDPtr, + i, + i1, + _$config.pointer, + z ? 1 : 0, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$12 = _class.staticMethodId( + r'createBitmap', + r'(IILandroid/graphics/Bitmap$Config;ZLandroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$12 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + jni$_.Pointer, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(int i, int i1, android.graphics.Bitmap$Config config, boolean z, android.graphics.ColorSpace colorSpace)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$12( + int i, + int i1, + Bitmap$Config? config, + bool z, + jni$_.JObject? colorSpace, + ) { + final _$config = config?.reference ?? jni$_.jNullReference; + final _$colorSpace = colorSpace?.reference ?? jni$_.jNullReference; + return _createBitmap$12( + _class.reference.pointer, + _id_createBitmap$12 as jni$_.JMethodIDPtr, + i, + i1, + _$config.pointer, + z ? 1 : 0, + _$colorSpace.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$13 = _class.staticMethodId( + r'createBitmap', + r'([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$13 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(int[] is, int i, int i1, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$13( + jni$_.JIntArray? is$, + int i, + int i1, + Bitmap$Config? config, + ) { + final _$is$ = is$?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$13( + _class.reference.pointer, + _id_createBitmap$13 as jni$_.JMethodIDPtr, + _$is$.pointer, + i, + i1, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createBitmap$14 = _class.staticMethodId( + r'createBitmap', + r'([IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;', + ); + + static final _createBitmap$14 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap createBitmap(int[] is, int i, int i1, int i2, int i3, android.graphics.Bitmap$Config config)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createBitmap$14( + jni$_.JIntArray? is$, + int i, + int i1, + int i2, + int i3, + Bitmap$Config? config, + ) { + final _$is$ = is$?.reference ?? jni$_.jNullReference; + final _$config = config?.reference ?? jni$_.jNullReference; + return _createBitmap$14( + _class.reference.pointer, + _id_createBitmap$14 as jni$_.JMethodIDPtr, + _$is$.pointer, + i, + i1, + i2, + i3, + _$config.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_createScaledBitmap = _class.staticMethodId( + r'createScaledBitmap', + r'(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;', + ); + + static final _createScaledBitmap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + int, + ) + >(); + + /// from: `static public android.graphics.Bitmap createScaledBitmap(android.graphics.Bitmap bitmap, int i, int i1, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? createScaledBitmap(Bitmap? bitmap, int i, int i1, bool z) { + final _$bitmap = bitmap?.reference ?? jni$_.jNullReference; + return _createScaledBitmap( + _class.reference.pointer, + _id_createScaledBitmap as jni$_.JMethodIDPtr, + _$bitmap.pointer, + i, + i1, + z ? 1 : 0, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_describeContents = _class.instanceMethodId( + r'describeContents', + r'()I', + ); + + static final _describeContents = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int describeContents()` + int describeContents() { + return _describeContents( + reference.pointer, + _id_describeContents as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_eraseColor = _class.instanceMethodId(r'eraseColor', r'(I)V'); + + static final _eraseColor = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void eraseColor(int i)` + void eraseColor(int i) { + _eraseColor( + reference.pointer, + _id_eraseColor as jni$_.JMethodIDPtr, + i, + ).check(); + } + + static final _id_eraseColor$1 = _class.instanceMethodId( + r'eraseColor', + r'(J)V', + ); + + static final _eraseColor$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int64,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void eraseColor(long j)` + void eraseColor$1(int j) { + _eraseColor$1( + reference.pointer, + _id_eraseColor$1 as jni$_.JMethodIDPtr, + j, + ).check(); + } + + static final _id_extractAlpha = _class.instanceMethodId( + r'extractAlpha', + r'()Landroid/graphics/Bitmap;', + ); + + static final _extractAlpha = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public android.graphics.Bitmap extractAlpha()` + /// The returned object must be released after use, by calling the [release] method. + Bitmap? extractAlpha() { + return _extractAlpha( + reference.pointer, + _id_extractAlpha as jni$_.JMethodIDPtr, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_extractAlpha$1 = _class.instanceMethodId( + r'extractAlpha', + r'(Landroid/graphics/Paint;[I)Landroid/graphics/Bitmap;', + ); + + static final _extractAlpha$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Pointer, jni$_.Pointer) + >, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + ) + >(); + + /// from: `public android.graphics.Bitmap extractAlpha(android.graphics.Paint paint, int[] is)` + /// The returned object must be released after use, by calling the [release] method. + Bitmap? extractAlpha$1(jni$_.JObject? paint, jni$_.JIntArray? is$) { + final _$paint = paint?.reference ?? jni$_.jNullReference; + final _$is$ = is$?.reference ?? jni$_.jNullReference; + return _extractAlpha$1( + reference.pointer, + _id_extractAlpha$1 as jni$_.JMethodIDPtr, + _$paint.pointer, + _$is$.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_getAllocationByteCount = _class.instanceMethodId( + r'getAllocationByteCount', + r'()I', + ); + + static final _getAllocationByteCount = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getAllocationByteCount()` + int getAllocationByteCount() { + return _getAllocationByteCount( + reference.pointer, + _id_getAllocationByteCount as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_getByteCount = _class.instanceMethodId( + r'getByteCount', + r'()I', + ); + + static final _getByteCount = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getByteCount()` + int getByteCount() { + return _getByteCount( + reference.pointer, + _id_getByteCount as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_getColor = _class.instanceMethodId( + r'getColor', + r'(II)Landroid/graphics/Color;', + ); + + static final _getColor = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + ) + >(); + + /// from: `public android.graphics.Color getColor(int i, int i1)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? getColor(int i, int i1) { + return _getColor( + reference.pointer, + _id_getColor as jni$_.JMethodIDPtr, + i, + i1, + ).object(const jni$_.$JObject$NullableType$()); + } + + static final _id_getColorSpace = _class.instanceMethodId( + r'getColorSpace', + r'()Landroid/graphics/ColorSpace;', + ); + + static final _getColorSpace = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public android.graphics.ColorSpace getColorSpace()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? getColorSpace() { + return _getColorSpace( + reference.pointer, + _id_getColorSpace as jni$_.JMethodIDPtr, + ).object(const jni$_.$JObject$NullableType$()); + } + + static final _id_getConfig = _class.instanceMethodId( + r'getConfig', + r'()Landroid/graphics/Bitmap$Config;', + ); + + static final _getConfig = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public android.graphics.Bitmap$Config getConfig()` + /// The returned object must be released after use, by calling the [release] method. + Bitmap$Config? getConfig() { + return _getConfig( + reference.pointer, + _id_getConfig as jni$_.JMethodIDPtr, + ).object(const $Bitmap$Config$NullableType$()); + } + + static final _id_getDensity = _class.instanceMethodId(r'getDensity', r'()I'); + + static final _getDensity = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getDensity()` + int getDensity() { + return _getDensity( + reference.pointer, + _id_getDensity as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_getGainmap = _class.instanceMethodId( + r'getGainmap', + r'()Landroid/graphics/Gainmap;', + ); + + static final _getGainmap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public android.graphics.Gainmap getGainmap()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? getGainmap() { + return _getGainmap( + reference.pointer, + _id_getGainmap as jni$_.JMethodIDPtr, + ).object(const jni$_.$JObject$NullableType$()); + } + + static final _id_getGenerationId = _class.instanceMethodId( + r'getGenerationId', + r'()I', + ); + + static final _getGenerationId = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getGenerationId()` + int getGenerationId() { + return _getGenerationId( + reference.pointer, + _id_getGenerationId as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_getHardwareBuffer = _class.instanceMethodId( + r'getHardwareBuffer', + r'()Landroid/hardware/HardwareBuffer;', + ); + + static final _getHardwareBuffer = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public android.hardware.HardwareBuffer getHardwareBuffer()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? getHardwareBuffer() { + return _getHardwareBuffer( + reference.pointer, + _id_getHardwareBuffer as jni$_.JMethodIDPtr, + ).object(const jni$_.$JObject$NullableType$()); + } + + static final _id_getHeight = _class.instanceMethodId(r'getHeight', r'()I'); + + static final _getHeight = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getHeight()` + int getHeight() { + return _getHeight( + reference.pointer, + _id_getHeight as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_getNinePatchChunk = _class.instanceMethodId( + r'getNinePatchChunk', + r'()[B', + ); + + static final _getNinePatchChunk = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public byte[] getNinePatchChunk()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JByteArray? getNinePatchChunk() { + return _getNinePatchChunk( + reference.pointer, + _id_getNinePatchChunk as jni$_.JMethodIDPtr, + ).object(const jni$_.$JByteArray$NullableType$()); + } + + static final _id_getPixel = _class.instanceMethodId(r'getPixel', r'(II)I'); + + static final _getPixel = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + ) + >(); + + /// from: `public int getPixel(int i, int i1)` + int getPixel(int i, int i1) { + return _getPixel( + reference.pointer, + _id_getPixel as jni$_.JMethodIDPtr, + i, + i1, + ).integer; + } + + static final _id_getPixels = _class.instanceMethodId( + r'getPixels', + r'([IIIIIII)V', + ); + + static final _getPixels = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + int, + int, + int, + int, + ) + >(); + + /// from: `public void getPixels(int[] is, int i, int i1, int i2, int i3, int i4, int i5)` + void getPixels( + jni$_.JIntArray? is$, + int i, + int i1, + int i2, + int i3, + int i4, + int i5, + ) { + final _$is$ = is$?.reference ?? jni$_.jNullReference; + _getPixels( + reference.pointer, + _id_getPixels as jni$_.JMethodIDPtr, + _$is$.pointer, + i, + i1, + i2, + i3, + i4, + i5, + ).check(); + } + + static final _id_getRowBytes = _class.instanceMethodId( + r'getRowBytes', + r'()I', + ); + + static final _getRowBytes = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getRowBytes()` + int getRowBytes() { + return _getRowBytes( + reference.pointer, + _id_getRowBytes as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_getScaledHeight = _class.instanceMethodId( + r'getScaledHeight', + r'(Landroid/graphics/Canvas;)I', + ); + + static final _getScaledHeight = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public int getScaledHeight(android.graphics.Canvas canvas)` + int getScaledHeight(jni$_.JObject? canvas) { + final _$canvas = canvas?.reference ?? jni$_.jNullReference; + return _getScaledHeight( + reference.pointer, + _id_getScaledHeight as jni$_.JMethodIDPtr, + _$canvas.pointer, + ).integer; + } + + static final _id_getScaledHeight$1 = _class.instanceMethodId( + r'getScaledHeight', + r'(Landroid/util/DisplayMetrics;)I', + ); + + static final _getScaledHeight$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public int getScaledHeight(android.util.DisplayMetrics displayMetrics)` + int getScaledHeight$1(jni$_.JObject? displayMetrics) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + return _getScaledHeight$1( + reference.pointer, + _id_getScaledHeight$1 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + ).integer; + } + + static final _id_getScaledHeight$2 = _class.instanceMethodId( + r'getScaledHeight', + r'(I)I', + ); + + static final _getScaledHeight$2 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public int getScaledHeight(int i)` + int getScaledHeight$2(int i) { + return _getScaledHeight$2( + reference.pointer, + _id_getScaledHeight$2 as jni$_.JMethodIDPtr, + i, + ).integer; + } + + static final _id_getScaledWidth = _class.instanceMethodId( + r'getScaledWidth', + r'(Landroid/graphics/Canvas;)I', + ); + + static final _getScaledWidth = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public int getScaledWidth(android.graphics.Canvas canvas)` + int getScaledWidth(jni$_.JObject? canvas) { + final _$canvas = canvas?.reference ?? jni$_.jNullReference; + return _getScaledWidth( + reference.pointer, + _id_getScaledWidth as jni$_.JMethodIDPtr, + _$canvas.pointer, + ).integer; + } + + static final _id_getScaledWidth$1 = _class.instanceMethodId( + r'getScaledWidth', + r'(Landroid/util/DisplayMetrics;)I', + ); + + static final _getScaledWidth$1 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public int getScaledWidth(android.util.DisplayMetrics displayMetrics)` + int getScaledWidth$1(jni$_.JObject? displayMetrics) { + final _$displayMetrics = displayMetrics?.reference ?? jni$_.jNullReference; + return _getScaledWidth$1( + reference.pointer, + _id_getScaledWidth$1 as jni$_.JMethodIDPtr, + _$displayMetrics.pointer, + ).integer; + } + + static final _id_getScaledWidth$2 = _class.instanceMethodId( + r'getScaledWidth', + r'(I)I', + ); + + static final _getScaledWidth$2 = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public int getScaledWidth(int i)` + int getScaledWidth$2(int i) { + return _getScaledWidth$2( + reference.pointer, + _id_getScaledWidth$2 as jni$_.JMethodIDPtr, + i, + ).integer; + } + + static final _id_getWidth = _class.instanceMethodId(r'getWidth', r'()I'); + + static final _getWidth = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public int getWidth()` + int getWidth() { + return _getWidth( + reference.pointer, + _id_getWidth as jni$_.JMethodIDPtr, + ).integer; + } + + static final _id_hasAlpha = _class.instanceMethodId(r'hasAlpha', r'()Z'); + + static final _hasAlpha = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public boolean hasAlpha()` + bool hasAlpha() { + return _hasAlpha( + reference.pointer, + _id_hasAlpha as jni$_.JMethodIDPtr, + ).boolean; + } + + static final _id_hasGainmap = _class.instanceMethodId(r'hasGainmap', r'()Z'); + + static final _hasGainmap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public boolean hasGainmap()` + bool hasGainmap() { + return _hasGainmap( + reference.pointer, + _id_hasGainmap as jni$_.JMethodIDPtr, + ).boolean; + } + + static final _id_hasMipMap = _class.instanceMethodId(r'hasMipMap', r'()Z'); + + static final _hasMipMap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public boolean hasMipMap()` + bool hasMipMap() { + return _hasMipMap( + reference.pointer, + _id_hasMipMap as jni$_.JMethodIDPtr, + ).boolean; + } + + static final _id_isMutable = _class.instanceMethodId(r'isMutable', r'()Z'); + + static final _isMutable = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public boolean isMutable()` + bool isMutable() { + return _isMutable( + reference.pointer, + _id_isMutable as jni$_.JMethodIDPtr, + ).boolean; + } + + static final _id_isPremultiplied = _class.instanceMethodId( + r'isPremultiplied', + r'()Z', + ); + + static final _isPremultiplied = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public boolean isPremultiplied()` + bool isPremultiplied() { + return _isPremultiplied( + reference.pointer, + _id_isPremultiplied as jni$_.JMethodIDPtr, + ).boolean; + } + + static final _id_isRecycled = _class.instanceMethodId(r'isRecycled', r'()Z'); + + static final _isRecycled = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public boolean isRecycled()` + bool isRecycled() { + return _isRecycled( + reference.pointer, + _id_isRecycled as jni$_.JMethodIDPtr, + ).boolean; + } + + static final _id_prepareToDraw = _class.instanceMethodId( + r'prepareToDraw', + r'()V', + ); + + static final _prepareToDraw = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void prepareToDraw()` + void prepareToDraw() { + _prepareToDraw( + reference.pointer, + _id_prepareToDraw as jni$_.JMethodIDPtr, + ).check(); + } + + static final _id_reconfigure = _class.instanceMethodId( + r'reconfigure', + r'(IILandroid/graphics/Bitmap$Config;)V', + ); + + static final _reconfigure = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Int32, jni$_.Int32, jni$_.Pointer) + >, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + jni$_.Pointer, + ) + >(); + + /// from: `public void reconfigure(int i, int i1, android.graphics.Bitmap$Config config)` + void reconfigure(int i, int i1, Bitmap$Config? config) { + final _$config = config?.reference ?? jni$_.jNullReference; + _reconfigure( + reference.pointer, + _id_reconfigure as jni$_.JMethodIDPtr, + i, + i1, + _$config.pointer, + ).check(); + } + + static final _id_recycle = _class.instanceMethodId(r'recycle', r'()V'); + + static final _recycle = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + ) + >(); + + /// from: `public void recycle()` + void recycle() { + _recycle(reference.pointer, _id_recycle as jni$_.JMethodIDPtr).check(); + } + + static final _id_sameAs = _class.instanceMethodId( + r'sameAs', + r'(Landroid/graphics/Bitmap;)Z', + ); + + static final _sameAs = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public boolean sameAs(android.graphics.Bitmap bitmap)` + bool sameAs(Bitmap? bitmap) { + final _$bitmap = bitmap?.reference ?? jni$_.jNullReference; + return _sameAs( + reference.pointer, + _id_sameAs as jni$_.JMethodIDPtr, + _$bitmap.pointer, + ).boolean; + } + + static final _id_setColorSpace = _class.instanceMethodId( + r'setColorSpace', + r'(Landroid/graphics/ColorSpace;)V', + ); + + static final _setColorSpace = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void setColorSpace(android.graphics.ColorSpace colorSpace)` + void setColorSpace(jni$_.JObject? colorSpace) { + final _$colorSpace = colorSpace?.reference ?? jni$_.jNullReference; + _setColorSpace( + reference.pointer, + _id_setColorSpace as jni$_.JMethodIDPtr, + _$colorSpace.pointer, + ).check(); + } + + static final _id_setConfig = _class.instanceMethodId( + r'setConfig', + r'(Landroid/graphics/Bitmap$Config;)V', + ); + + static final _setConfig = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void setConfig(android.graphics.Bitmap$Config config)` + void setConfig(Bitmap$Config? config) { + final _$config = config?.reference ?? jni$_.jNullReference; + _setConfig( + reference.pointer, + _id_setConfig as jni$_.JMethodIDPtr, + _$config.pointer, + ).check(); + } + + static final _id_setDensity = _class.instanceMethodId(r'setDensity', r'(I)V'); + + static final _setDensity = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void setDensity(int i)` + void setDensity(int i) { + _setDensity( + reference.pointer, + _id_setDensity as jni$_.JMethodIDPtr, + i, + ).check(); + } + + static final _id_setGainmap = _class.instanceMethodId( + r'setGainmap', + r'(Landroid/graphics/Gainmap;)V', + ); + + static final _setGainmap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + ) + >(); + + /// from: `public void setGainmap(android.graphics.Gainmap gainmap)` + void setGainmap(jni$_.JObject? gainmap) { + final _$gainmap = gainmap?.reference ?? jni$_.jNullReference; + _setGainmap( + reference.pointer, + _id_setGainmap as jni$_.JMethodIDPtr, + _$gainmap.pointer, + ).check(); + } + + static final _id_setHasAlpha = _class.instanceMethodId( + r'setHasAlpha', + r'(Z)V', + ); + + static final _setHasAlpha = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void setHasAlpha(boolean z)` + void setHasAlpha(bool z) { + _setHasAlpha( + reference.pointer, + _id_setHasAlpha as jni$_.JMethodIDPtr, + z ? 1 : 0, + ).check(); + } + + static final _id_setHasMipMap = _class.instanceMethodId( + r'setHasMipMap', + r'(Z)V', + ); + + static final _setHasMipMap = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void setHasMipMap(boolean z)` + void setHasMipMap(bool z) { + _setHasMipMap( + reference.pointer, + _id_setHasMipMap as jni$_.JMethodIDPtr, + z ? 1 : 0, + ).check(); + } + + static final _id_setHeight = _class.instanceMethodId(r'setHeight', r'(I)V'); + + static final _setHeight = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void setHeight(int i)` + void setHeight(int i) { + _setHeight( + reference.pointer, + _id_setHeight as jni$_.JMethodIDPtr, + i, + ).check(); + } + + static final _id_setPixel = _class.instanceMethodId(r'setPixel', r'(III)V'); + + static final _setPixel = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32, jni$_.Int32)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + int, + int, + ) + >(); + + /// from: `public void setPixel(int i, int i1, int i2)` + void setPixel(int i, int i1, int i2) { + _setPixel( + reference.pointer, + _id_setPixel as jni$_.JMethodIDPtr, + i, + i1, + i2, + ).check(); + } + + static final _id_setPixels = _class.instanceMethodId( + r'setPixels', + r'([IIIIIII)V', + ); + + static final _setPixels = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + ) + >, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + int, + int, + int, + int, + int, + ) + >(); + + /// from: `public void setPixels(int[] is, int i, int i1, int i2, int i3, int i4, int i5)` + void setPixels( + jni$_.JIntArray? is$, + int i, + int i1, + int i2, + int i3, + int i4, + int i5, + ) { + final _$is$ = is$?.reference ?? jni$_.jNullReference; + _setPixels( + reference.pointer, + _id_setPixels as jni$_.JMethodIDPtr, + _$is$.pointer, + i, + i1, + i2, + i3, + i4, + i5, + ).check(); + } + + static final _id_setPremultiplied = _class.instanceMethodId( + r'setPremultiplied', + r'(Z)V', + ); + + static final _setPremultiplied = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void setPremultiplied(boolean z)` + void setPremultiplied(bool z) { + _setPremultiplied( + reference.pointer, + _id_setPremultiplied as jni$_.JMethodIDPtr, + z ? 1 : 0, + ).check(); + } + + static final _id_setWidth = _class.instanceMethodId(r'setWidth', r'(I)V'); + + static final _setWidth = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + int, + ) + >(); + + /// from: `public void setWidth(int i)` + void setWidth(int i) { + _setWidth(reference.pointer, _id_setWidth as jni$_.JMethodIDPtr, i).check(); + } + + static final _id_wrapHardwareBuffer = _class.staticMethodId( + r'wrapHardwareBuffer', + r'(Landroid/hardware/HardwareBuffer;Landroid/graphics/ColorSpace;)Landroid/graphics/Bitmap;', + ); + + static final _wrapHardwareBuffer = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + (jni$_.Pointer, jni$_.Pointer) + >, + ) + > + >('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + ) + >(); + + /// from: `static public android.graphics.Bitmap wrapHardwareBuffer(android.hardware.HardwareBuffer hardwareBuffer, android.graphics.ColorSpace colorSpace)` + /// The returned object must be released after use, by calling the [release] method. + static Bitmap? wrapHardwareBuffer( + jni$_.JObject? hardwareBuffer, + jni$_.JObject? colorSpace, + ) { + final _$hardwareBuffer = hardwareBuffer?.reference ?? jni$_.jNullReference; + final _$colorSpace = colorSpace?.reference ?? jni$_.jNullReference; + return _wrapHardwareBuffer( + _class.reference.pointer, + _id_wrapHardwareBuffer as jni$_.JMethodIDPtr, + _$hardwareBuffer.pointer, + _$colorSpace.pointer, + ).object(const $Bitmap$NullableType$()); + } + + static final _id_writeToParcel = _class.instanceMethodId( + r'writeToParcel', + r'(Landroid/os/Parcel;I)V', + ); + + static final _writeToParcel = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer, jni$_.Int32)>, + ) + > + >('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + ) + >(); + + /// from: `public void writeToParcel(android.os.Parcel parcel, int i)` + void writeToParcel(jni$_.JObject? parcel, int i) { + final _$parcel = parcel?.reference ?? jni$_.jNullReference; + _writeToParcel( + reference.pointer, + _id_writeToParcel as jni$_.JMethodIDPtr, + _$parcel.pointer, + i, + ).check(); + } +} + +final class $Bitmap$NullableType$ extends jni$_.JType { + @jni$_.internal + const $Bitmap$NullableType$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/Bitmap;'; + + @jni$_.internal + @core$_.override + Bitmap? fromReference(jni$_.JReference reference) => + reference.isNull ? null : Bitmap.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($Bitmap$NullableType$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($Bitmap$NullableType$) && + other is $Bitmap$NullableType$; + } +} + +final class $Bitmap$Type$ extends jni$_.JType { + @jni$_.internal + const $Bitmap$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Landroid/graphics/Bitmap;'; + + @jni$_.internal + @core$_.override + Bitmap fromReference(jni$_.JReference reference) => + Bitmap.fromReference(reference); + @jni$_.internal + @core$_.override + jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + + @jni$_.internal + @core$_.override + jni$_.JType get nullableType => const $Bitmap$NullableType$(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($Bitmap$Type$).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($Bitmap$Type$) && other is $Bitmap$Type$; + } +} diff --git a/lib/image_ffi.dart b/lib/image_ffi.dart index 0d1fbd6..ee507f3 100644 --- a/lib/image_ffi.dart +++ b/lib/image_ffi.dart @@ -1,131 +1,121 @@ +library; import 'dart:async'; -import 'dart:ffi'; -import 'dart:io'; -import 'dart:isolate'; -import 'image_ffi_bindings_generated.dart'; +import 'package:flutter/foundation.dart'; +import 'package:image_ffi/src/image_converter_android.dart'; +import 'package:image_ffi/src/image_converter_darwin.dart'; +import 'package:image_ffi/src/image_converter_platform_interface.dart'; +import 'package:image_ffi/src/output_format.dart'; -/// A very short-lived native function. -/// -/// For very short-lived functions, it is fine to call them on the main isolate. -/// They will block the Dart execution while running the native function, so -/// only do this for native functions which are guaranteed to be short-lived. -int sum(int a, int b) => _bindings.sum(a, b); +export 'src/output_format.dart'; -/// A longer lived native function, which occupies the thread calling it. +/// Main entry point for image format conversion. /// -/// Do not call these kind of native functions in the main isolate. They will -/// block Dart execution. This will cause dropped frames in Flutter applications. -/// Instead, call these native functions on a separate isolate. -/// -/// Modify this to suit your own use case. Example use cases: -/// -/// 1. Reuse a single isolate for various different kinds of requests. -/// 2. Use multiple helper isolates for parallel execution. -Future sumAsync(int a, int b) async { - final SendPort helperIsolateSendPort = await _helperIsolateSendPort; - final int requestId = _nextSumRequestId++; - final _SumRequest request = _SumRequest(requestId, a, b); - final Completer completer = Completer(); - _sumRequests[requestId] = completer; - helperIsolateSendPort.send(request); - return completer.future; +/// Provides a platform-agnostic interface to convert images across iOS, +/// macOS, and Android platforms using native APIs. +class ImageConverter { + /// The platform-specific implementation of the image converter. + /// + /// This is initialized based on the current platform. + static ImageConverterPlatform get _platform => + _getPlatformForTarget(defaultTargetPlatform); + + /// Converts an image to a target format. + /// + /// By default, this operation is performed in a separate isolate to avoid + /// blocking the UI thread. For very small images, the overhead of an isolate + /// can be disabled by setting [runInIsolate] to `false`. + /// + /// **Parameters:** + /// - [inputData]: Raw bytes of the image to convert. + /// - [format]: Target [OutputFormat]. Defaults to [OutputFormat.jpeg]. + /// - [quality]: Compression quality for lossy formats (1-100). + /// - [runInIsolate]: Whether to run the conversion in a separate isolate. + /// Defaults to `true`. + /// + /// **Returns:** A [Future] that completes with the converted image data. + /// + /// **Throws:** + /// - [UnsupportedError]: If the platform or output format is not supported. + /// - [Exception]: If the image decoding or encoding fails. + /// + /// **Example - Convert HEIC to JPEG:** + /// ```dart + /// final jpegData = await ImageConverter.convert( + /// inputData: heicImageData, + /// format: OutputFormat.jpeg, + /// quality: 90, + /// ); + /// ``` + /// + /// **Example - Running on the main thread:** + /// ```dart + /// // Only do this for very small images where isolate overhead is a concern. + /// final pngData = await ImageConverter.convert( + /// inputData: smallImageData, + /// format: OutputFormat.png, + /// runInIsolate: false, + /// ); + /// ``` + static Future convert({ + required Uint8List inputData, + OutputFormat format = OutputFormat.jpeg, + int quality = 100, + bool runInIsolate = true, + }) { + if (runInIsolate) { + return compute( + _convertInIsolate, + _ConvertRequest(inputData, format, quality, defaultTargetPlatform), + ); + } else { + // The original implementation for those who opt-out. + return _platform.convert( + inputData: inputData, + format: format, + quality: quality, + ); + } + } } -const String _libName = 'image_ffi'; +/// Helper class to pass arguments to the isolate. +@immutable +class _ConvertRequest { + final Uint8List inputData; + final OutputFormat format; + final int quality; + final TargetPlatform platform; -/// The dynamic library in which the symbols for [ImageFfiBindings] can be found. -final DynamicLibrary _dylib = () { - if (Platform.isMacOS || Platform.isIOS) { - return DynamicLibrary.open('$_libName.framework/$_libName'); - } - if (Platform.isAndroid || Platform.isLinux) { - return DynamicLibrary.open('lib$_libName.so'); - } - if (Platform.isWindows) { - return DynamicLibrary.open('$_libName.dll'); - } - throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); -}(); - -/// The bindings to the native functions in [_dylib]. -final ImageFfiBindings _bindings = ImageFfiBindings(_dylib); - - -/// A request to compute `sum`. -/// -/// Typically sent from one isolate to another. -class _SumRequest { - final int id; - final int a; - final int b; - - const _SumRequest(this.id, this.a, this.b); + const _ConvertRequest( + this.inputData, + this.format, + this.quality, + this.platform, + ); } -/// A response with the result of `sum`. -/// -/// Typically sent from one isolate to another. -class _SumResponse { - final int id; - final int result; - - const _SumResponse(this.id, this.result); +/// Returns the platform-specific converter instance. +ImageConverterPlatform _getPlatformForTarget(TargetPlatform platform) { + if (kIsWeb) { + throw UnsupportedError('Image conversion is not supported on the web.'); + } + return switch (platform) { + TargetPlatform.android => ImageConverterAndroid(), + TargetPlatform.iOS || TargetPlatform.macOS => ImageConverterDarwin(), + _ => throw UnsupportedError( + 'Image conversion is not supported on this platform: $platform', + ), + }; } -/// Counter to identify [_SumRequest]s and [_SumResponse]s. -int _nextSumRequestId = 0; - -/// Mapping from [_SumRequest] `id`s to the completers corresponding to the correct future of the pending request. -final Map> _sumRequests = >{}; - -/// The SendPort belonging to the helper isolate. -Future _helperIsolateSendPort = () async { - // The helper isolate is going to send us back a SendPort, which we want to - // wait for. - final Completer completer = Completer(); - - // Receive port on the main isolate to receive messages from the helper. - // We receive two types of messages: - // 1. A port to send messages on. - // 2. Responses to requests we sent. - final ReceivePort receivePort = ReceivePort() - ..listen((dynamic data) { - if (data is SendPort) { - // The helper isolate sent us the port on which we can sent it requests. - completer.complete(data); - return; - } - if (data is _SumResponse) { - // The helper isolate sent us a response to a request we sent. - final Completer completer = _sumRequests[data.id]!; - _sumRequests.remove(data.id); - completer.complete(data.result); - return; - } - throw UnsupportedError('Unsupported message type: ${data.runtimeType}'); - }); - - // Start the helper isolate. - await Isolate.spawn((SendPort sendPort) async { - final ReceivePort helperReceivePort = ReceivePort() - ..listen((dynamic data) { - // On the helper isolate listen to requests and respond to them. - if (data is _SumRequest) { - final int result = _bindings.sum_long_running(data.a, data.b); - final _SumResponse response = _SumResponse(data.id, result); - sendPort.send(response); - return; - } - throw UnsupportedError('Unsupported message type: ${data.runtimeType}'); - }); - - // Send the port to the main isolate on which we can receive requests. - sendPort.send(helperReceivePort.sendPort); - }, receivePort.sendPort); - - // Wait until the helper isolate has sent us back the SendPort on which we - // can start sending requests. - return completer.future; -}(); +/// Top-level function for `compute`. +Future _convertInIsolate(_ConvertRequest request) { + final platform = _getPlatformForTarget(request.platform); + return platform.convert( + inputData: request.inputData, + format: request.format, + quality: request.quality, + ); +} diff --git a/lib/image_ffi_bindings_generated.dart b/lib/image_ffi_bindings_generated.dart deleted file mode 100644 index 422bfa5..0000000 --- a/lib/image_ffi_bindings_generated.dart +++ /dev/null @@ -1,69 +0,0 @@ -// ignore_for_file: always_specify_types -// ignore_for_file: camel_case_types -// ignore_for_file: non_constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -// ignore_for_file: type=lint -import 'dart:ffi' as ffi; - -/// Bindings for `src/image_ffi.h`. -/// -/// Regenerate bindings with `dart run ffigen --config ffigen.yaml`. -/// -class ImageFfiBindings { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - ImageFfiBindings(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - ImageFfiBindings.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) - : _lookup = lookup; - - /// A very short-lived native function. - /// - /// For very short-lived functions, it is fine to call them on the main isolate. - /// They will block the Dart execution while running the native function, so - /// only do this for native functions which are guaranteed to be short-lived. - int sum( - int a, - int b, - ) { - return _sum( - a, - b, - ); - } - - late final _sumPtr = - _lookup>('sum'); - late final _sum = _sumPtr.asFunction(); - - /// A longer lived native function, which occupies the thread calling it. - /// - /// Do not call these kind of native functions in the main isolate. They will - /// block Dart execution. This will cause dropped frames in Flutter applications. - /// Instead, call these native functions on a separate isolate. - int sum_long_running( - int a, - int b, - ) { - return _sum_long_running( - a, - b, - ); - } - - late final _sum_long_runningPtr = - _lookup>( - 'sum_long_running'); - late final _sum_long_running = - _sum_long_runningPtr.asFunction(); -} diff --git a/lib/src/image_converter_android.dart b/lib/src/image_converter_android.dart new file mode 100644 index 0000000..1a4febc --- /dev/null +++ b/lib/src/image_converter_android.dart @@ -0,0 +1,93 @@ +import 'dart:typed_data'; + +import 'package:image_ffi/gen/jnigen_bindings.dart'; +import 'package:image_ffi/src/image_converter_platform_interface.dart'; +import 'package:image_ffi/src/output_format.dart'; +import 'package:jni/jni.dart'; + +/// Android image converter using BitmapFactory and Bitmap compression. +/// +/// Implements image conversion for Android 9+ (API level 28+) platforms using +/// BitmapFactory for decoding and Bitmap.compress for encoding via JNI.\n/// +/// **Features:** +/// - Supports JPEG, PNG, WebP, GIF, BMP input formats +/// - Can read HEIC files (Android 9+) +/// - Cannot write HEIC (throws UnsupportedError) +/// - Efficient memory usage with ByteArrayOutputStream +/// +/// **API Stack:** +/// - `BitmapFactory.decodeByteArray`: Auto-detect and decode input +/// - `Bitmap.compress`: Encode to target format with quality control +/// - `ByteArrayOutputStream`: Memory-based output buffer +/// +/// **Limitations:** +/// - HEIC output not supported (use JPEG or PNG instead) +/// - Requires Android 9+ for full format support +/// +/// **Performance:** +/// - Native image decoding via BitmapFactory +/// - Efficient compression with quality adjustment +final class ImageConverterAndroid implements ImageConverterPlatform { + @override + Future convert({ + required Uint8List inputData, + OutputFormat format = OutputFormat.jpeg, + int quality = 100, + }) async { + final inputJBytes = JByteArray.from(inputData); + try { + final bitmap = BitmapFactory.decodeByteArray( + inputJBytes, + 0, + inputData.length, + ); + if (bitmap == null) { + throw Exception('Failed to decode image. Invalid image data.'); + } + + try { + final compressFormat = switch (format) { + OutputFormat.jpeg => Bitmap$CompressFormat.JPEG, + OutputFormat.png => Bitmap$CompressFormat.PNG, + OutputFormat.webp => Bitmap$CompressFormat.WEBP_LOSSY, + OutputFormat.heic => throw UnsupportedError( + 'HEIC output format is not supported on Android.', + ), + }; + + try { + final outputStream = ByteArrayOutputStream(); + try { + final success = bitmap.compress( + compressFormat, + quality, + outputStream, + ); + if (!success) { + throw Exception('Failed to compress bitmap.'); + } + + final outputJBytes = outputStream.toByteArray(); + if (outputJBytes == null) { + throw Exception('Failed to get byte array from output stream.'); + } + try { + final outputList = outputJBytes.toList(); + return Uint8List.fromList(outputList); + } finally { + outputJBytes.release(); + } + } finally { + outputStream.release(); + } + } finally { + compressFormat.release(); + } + } finally { + bitmap.release(); + } + } finally { + inputJBytes.release(); + } + } +} diff --git a/lib/src/image_converter_darwin.dart b/lib/src/image_converter_darwin.dart new file mode 100644 index 0000000..47484e4 --- /dev/null +++ b/lib/src/image_converter_darwin.dart @@ -0,0 +1,112 @@ +import 'dart:ffi'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; +import 'package:image_ffi/gen/darwin_bindings.dart'; +import 'package:image_ffi/src/image_converter_platform_interface.dart'; +import 'package:image_ffi/src/output_format.dart'; +import 'package:objective_c/objective_c.dart'; + +/// iOS/macOS image converter using ImageIO framework. +/// +/// Implements image conversion for iOS 14+ and macOS 10.15+ platforms using +/// the native ImageIO framework through FFI bindings. +/// +/// **Features:** +/// - Supports all major image formats (JPEG, PNG, HEIC, WebP, etc.) +/// - Uses CoreFoundation and CoreGraphics for efficient processing +/// - Memory-safe with proper resource cleanup +/// +/// **API Stack:** +/// - `CGImageSourceCreateWithData`: Decode input image +/// - `CGImageSourceCreateImageAtIndex`: Extract CGImage +/// - `CGImageDestinationCreateWithData`: Create output stream +/// - `CGImageDestinationAddImage`: Add image with encoding options +/// - `CGImageDestinationFinalize`: Complete encoding +/// +/// **Performance:** +/// - Direct FFI calls with minimal overhead +/// - In-memory processing +/// - Adjustable JPEG/WebP quality for size optimization +final class ImageConverterDarwin implements ImageConverterPlatform { + @override + Future convert({ + required Uint8List inputData, + OutputFormat format = OutputFormat.jpeg, + int quality = 100, + }) async { + final inputPtr = calloc(inputData.length); + try { + inputPtr.asTypedList(inputData.length).setAll(0, inputData); + + final cfData = CFDataCreate( + kCFAllocatorDefault, + inputPtr.cast(), + inputData.length, + ); + if (cfData == nullptr) { + throw Exception('Failed to create CFData from input data.'); + } + + final imageSource = CGImageSourceCreateWithData(cfData, nullptr); + if (imageSource == nullptr) { + throw Exception('Failed to create CGImageSource. Invalid image data.'); + } + + final cgImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nullptr); + if (cgImage == nullptr) { + throw Exception('Failed to decode image.'); + } + + final outputData = CFDataCreateMutable(kCFAllocatorDefault, 0); + if (outputData == nullptr) { + throw Exception('Failed to create output CFData.'); + } + + final utiStr = switch (format) { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttypejpeg + OutputFormat.jpeg => 'public.jpeg', + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttypepng + OutputFormat.png => 'public.png', + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttypeheic + OutputFormat.heic => 'public.heic', + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttypewebp + OutputFormat.webp => throw UnsupportedError( + 'WebP output format is not supported on iOS/macOS via ImageIO.', + ), + }; + final cfString = utiStr + .toNSString() + .ref + .retainAndAutorelease() + .cast(); + + final destination = CGImageDestinationCreateWithData( + outputData, + cfString, + 1, + nullptr, + ); + if (destination == nullptr) { + throw Exception('Failed to create CGImageDestination.'); + } + + CGImageDestinationAddImage(destination, cgImage, nullptr); + + final success = CGImageDestinationFinalize(destination); + if (!success) { + throw Exception('Failed to finalize image encoding.'); + } + + final length = CFDataGetLength(outputData); + final bytePtr = CFDataGetBytePtr(outputData); + if (bytePtr == nullptr) { + throw Exception('Failed to get output data bytes.'); + } + + return Uint8List.fromList(bytePtr.cast().asTypedList(length)); + } finally { + calloc.free(inputPtr); + } + } +} diff --git a/lib/src/image_converter_platform_interface.dart b/lib/src/image_converter_platform_interface.dart new file mode 100644 index 0000000..e8716a9 --- /dev/null +++ b/lib/src/image_converter_platform_interface.dart @@ -0,0 +1,36 @@ +import 'dart:typed_data'; + +import 'output_format.dart'; + +/// Platform-specific image converter interface. +/// +/// Abstract base class that all platform implementations must implement. +/// Handles the core logic of image format conversion on each platform. +/// +/// **Implementations:** +/// - [ImageConverterDarwin]: iOS and macOS using ImageIO +/// - [ImageConverterAndroid]: Android using BitmapFactory +abstract interface class ImageConverterPlatform { + /// Converts an image to a target format. + /// + /// Decodes the input image data and re-encodes it in the specified format. + /// + /// **Parameters:** + /// - [inputData]: Raw bytes of the image to convert + /// - [format]: Target [OutputFormat] (default: [OutputFormat.jpeg]) + /// - [quality]: Compression quality 1-100 for lossy formats (default: 95) + /// + /// **Returns:** Converted image data as [Uint8List] + /// + /// **Throws:** + /// - [UnimplementedError]: If not implemented by platform subclass + /// - [UnsupportedError]: If format is not supported + /// - [Exception]: If conversion fails + Future convert({ + required Uint8List inputData, + OutputFormat format = OutputFormat.jpeg, + int quality = 100, + }) { + throw UnimplementedError('convert() has not been implemented.'); + } +} diff --git a/lib/src/output_format.dart b/lib/src/output_format.dart new file mode 100644 index 0000000..0149ade --- /dev/null +++ b/lib/src/output_format.dart @@ -0,0 +1,32 @@ +/// Output image format for conversion. +/// +/// Specifies the target format when converting images. +/// +/// **Format Support:** +/// | Format | iOS/macOS | Android | +/// |--------|-----------|---------| +/// | jpeg | ✓ | ✓ | +/// | png | ✓ | ✓ | +/// | webp | ✓ | ✓ | +/// +/// **Notes:** +/// - [jpeg]: Good compression with adjustable quality +/// - [png]: Lossless compression, supports transparency +/// - [webp]: Modern format with better compression than JPEG +enum OutputFormat { + /// JPEG format (.jpg, .jpeg) + /// Lossy compression, suitable for photos + jpeg, + + /// PNG format (.png) + /// Lossless compression, supports transparency + png, + + /// WebP format (.webp) + /// Modern format with superior compression (not supported on Darwin) + webp, + + /// HEIC format (.heic) + /// High Efficiency Image Format (not supported on Android) + heic, +} diff --git a/pubspec.yaml b/pubspec.yaml index 147ac12..637ac85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: image_ffi -description: "A new Flutter FFI plugin project." +description: "A high-performance Flutter plugin for cross-platform image format conversion using native APIs." version: 0.0.1 -homepage: +homepage: https://github.com/koji-1009/image_ffi environment: sdk: ^3.10.0 @@ -10,19 +10,13 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.0.2 - + jni: ^0.15.2 + ffi: ^2.1.4 + objective_c: ^9.2.1 + dev_dependencies: - ffi: ^2.1.3 - ffigen: ^20.0.0 flutter_test: sdk: flutter flutter_lints: ^6.0.0 - -flutter: - plugin: - platforms: - android: - ffiPlugin: true - ios: - ffiPlugin: true + jnigen: ^0.15.0 + ffigen: ^20.1.1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 8a59108..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# The Flutter tooling requires that developers have CMake 3.10 or later -# installed. You should not increase this version, as doing so will cause -# the plugin to fail to compile for some customers of the plugin. -cmake_minimum_required(VERSION 3.10) - -project(image_ffi_library VERSION 0.0.1 LANGUAGES C) - -add_library(image_ffi SHARED - "image_ffi.c" -) - -set_target_properties(image_ffi PROPERTIES - PUBLIC_HEADER image_ffi.h - OUTPUT_NAME "image_ffi" -) - -target_compile_definitions(image_ffi PUBLIC DART_SHARED_LIB) - -if (ANDROID) - # Support Android 15 16k page size - target_link_options(image_ffi PRIVATE "-Wl,-z,max-page-size=16384") -endif() diff --git a/src/image_ffi.c b/src/image_ffi.c deleted file mode 100644 index f34ae95..0000000 --- a/src/image_ffi.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "image_ffi.h" - -// A very short-lived native function. -// -// For very short-lived functions, it is fine to call them on the main isolate. -// They will block the Dart execution while running the native function, so -// only do this for native functions which are guaranteed to be short-lived. -FFI_PLUGIN_EXPORT int sum(int a, int b) { return a + b; } - -// A longer-lived native function, which occupies the thread calling it. -// -// Do not call these kind of native functions in the main isolate. They will -// block Dart execution. This will cause dropped frames in Flutter applications. -// Instead, call these native functions on a separate isolate. -FFI_PLUGIN_EXPORT int sum_long_running(int a, int b) { - // Simulate work. -#if _WIN32 - Sleep(5000); -#else - usleep(5000 * 1000); -#endif - return a + b; -} diff --git a/src/image_ffi.h b/src/image_ffi.h deleted file mode 100644 index 7944459..0000000 --- a/src/image_ffi.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -#if _WIN32 -#include -#else -#include -#include -#endif - -#if _WIN32 -#define FFI_PLUGIN_EXPORT __declspec(dllexport) -#else -#define FFI_PLUGIN_EXPORT -#endif - -// A very short-lived native function. -// -// For very short-lived functions, it is fine to call them on the main isolate. -// They will block the Dart execution while running the native function, so -// only do this for native functions which are guaranteed to be short-lived. -FFI_PLUGIN_EXPORT int sum(int a, int b); - -// A longer lived native function, which occupies the thread calling it. -// -// Do not call these kind of native functions in the main isolate. They will -// block Dart execution. This will cause dropped frames in Flutter applications. -// Instead, call these native functions on a separate isolate. -FFI_PLUGIN_EXPORT int sum_long_running(int a, int b); From af7d73d086fd64c7081dff6006b28a46bf3f3701 Mon Sep 17 00:00:00 2001 From: Koji Wakamiya Date: Mon, 8 Dec 2025 11:03:46 +0900 Subject: [PATCH 2/3] chore: example project --- example/ios/Runner.xcodeproj/project.pbxproj | 22 ++ .../xcshareddata/xcschemes/Runner.xcscheme | 18 ++ example/lib/main.dart | 176 +++++++---- example/pubspec.lock | 273 +++++++++++++++++- example/pubspec.yaml | 78 +---- 5 files changed, 432 insertions(+), 135 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index adaa87b..083dbae 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -55,6 +56,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,6 +64,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -79,6 +82,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, @@ -142,6 +146,9 @@ productType = "com.apple.product-type.bundle.unit-test"; }; 97C146ED1CF9000F007C117D /* Runner */ = { + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( @@ -165,6 +172,9 @@ /* Begin PBXProject section */ 97C146E61CF9000F007C117D /* Project object */ = { + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, + ); isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; @@ -611,6 +621,18 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index e3773d4..c3fedb2 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + createState() => _MyAppState(); + Widget build(BuildContext context) { + return MaterialApp( + title: 'Image FFI Demo', + theme: ThemeData.light(), + home: MainPage(), + ); + } } -class _MyAppState extends State { - late int sumResult; - late Future sumAsyncResult; +class MainPage extends StatefulWidget { + const MainPage({super.key}); @override - void initState() { - super.initState(); - sumResult = image_ffi.sum(1, 2); - sumAsyncResult = image_ffi.sumAsync(3, 4); + State createState() => _MainPageState(); +} + +class _MainPageState extends State { + Uint8List? _originalImage; + String? _originalName; + Uint8List? _convertedImage; + String? _convertedFormat; + int? _convertElapsedMs; + bool _isLoading = false; + + Future _pickImage() async { + final picker = ImagePicker(); + final pickedFile = await picker.pickImage(source: ImageSource.gallery); + if (pickedFile != null) { + _originalImage = await pickedFile.readAsBytes(); + _originalName = pickedFile.name; + _convertedImage = null; + _convertedFormat = null; + _convertElapsedMs = null; + setState(() {}); + } + } + + Future _convertImage(OutputFormat format) async { + if (_originalImage == null) return; + setState(() => _isLoading = true); + final sw = Stopwatch()..start(); + try { + final converted = await ImageConverter.convert( + inputData: _originalImage!, + format: format, + quality: 90, + ); + sw.stop(); + _convertedImage = converted; + _convertedFormat = format.name; + _convertElapsedMs = sw.elapsedMilliseconds; + setState(() {}); + } catch (e) { + if (!mounted) return; + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text('Conversion failed: $e'))); + } finally { + setState(() => _isLoading = false); + } } @override Widget build(BuildContext context) { - const textStyle = TextStyle(fontSize: 25); - const spacerSmall = SizedBox(height: 10); - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Native Packages'), - ), - body: SingleChildScrollView( - child: Container( - padding: const .all(10), - child: Column( - children: [ - const Text( - 'This calls a native function through FFI that is shipped as source in the package. ' - 'The native code is built as part of the Flutter Runner build.', - style: textStyle, - textAlign: .center, - ), - spacerSmall, - Text( - 'sum(1, 2) = $sumResult', - style: textStyle, - textAlign: .center, - ), - spacerSmall, - FutureBuilder( - future: sumAsyncResult, - builder: (BuildContext context, AsyncSnapshot value) { - final displayValue = - (value.hasData) ? value.data : 'loading'; - return Text( - 'await sumAsync(3, 4) = $displayValue', - style: textStyle, - textAlign: .center, - ); - }, - ), - ], + return Scaffold( + appBar: AppBar(title: const Text('image_ffi Demo')), + body: SingleChildScrollView( + padding: const .all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + FilledButton( + onPressed: _pickImage, + child: const Text('Pick Image'), ), - ), + if (_originalImage != null) ...[ + Text('Original Image ($_originalName): '), + Image.memory(_originalImage!, height: 180), + const SizedBox(height: 8), + Row( + spacing: 4, + children: [ + ActionChip( + onPressed: _isLoading + ? null + : () => _convertImage(OutputFormat.jpeg), + label: const Text('to JPG'), + ), + ActionChip( + onPressed: _isLoading + ? null + : () => _convertImage(OutputFormat.png), + label: const Text('to PNG'), + ), + ActionChip( + onPressed: _isLoading + ? null + : () => _convertImage(OutputFormat.webp), + label: const Text('to WebP'), + ), + ActionChip( + onPressed: _isLoading + ? null + : () => _convertImage(OutputFormat.heic), + label: const Text('to HEIC'), + ), + ], + ), + ], + if (_isLoading) + const Padding( + padding: .all(16), + child: Center(child: CircularProgressIndicator()), + ), + if (!_isLoading && _convertedImage != null) + Column( + children: [ + Text('Converted ($_convertedFormat):'), + Image.memory(_convertedImage!, height: 180), + Text('Size: ${_convertedImage!.lengthInBytes} bytes'), + if (_convertElapsedMs != null) + Text('Convert time: $_convertElapsedMs ms'), + ], + ), + ], ), ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index bd9b284..575b636 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" async: dependency: transitive description: @@ -33,6 +41,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: ae0db647e668cbb295a3527f0938e4039e004c80099dce2f964102373f5ce0b5 + url: "https://pub.dev" + source: hosted + version: "0.19.10" collection: dependency: transitive description: @@ -41,14 +57,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.19.1" - cupertino_icons: - dependency: "direct main" + cross_file: + dependency: transitive description: - name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + name: cross_file + sha256: "701dcfc06da0882883a2657c445103380e53e647060ad8d9dfb710c100996608" url: "https://pub.dev" source: hosted - version: "1.0.8" + version: "0.3.5+1" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" fake_async: dependency: transitive description: @@ -57,6 +81,54 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0" + url: "https://pub.dev" + source: hosted + version: "0.9.4" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a" + url: "https://pub.dev" + source: hosted + version: "0.9.5" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85" + url: "https://pub.dev" + source: hosted + version: "2.7.0" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd" + url: "https://pub.dev" + source: hosted + version: "0.9.3+5" flutter: dependency: "direct main" description: flutter @@ -70,11 +142,56 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1 + url: "https://pub.dev" + source: hosted + version: "2.0.33" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + hooks: + dependency: transitive + description: + name: hooks + sha256: "5410b9f4f6c9f01e8ff0eb81c9801ea13a3c3d39f8f0b1613cda08e27eab3c18" + url: "https://pub.dev" + source: hosted + version: "0.20.5" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" image_ffi: dependency: "direct main" description: @@ -82,6 +199,78 @@ packages: relative: true source: path version: "0.0.1" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "784210112be18ea55f69d7076e2c656a4e24949fa9e76429fe53af0c0f4fa320" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "5e9bf126c37c117cf8094215373c6d561117a3cfb50ebc5add1a61dc6e224677" + url: "https://pub.dev" + source: hosted + version: "0.8.13+10" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: "956c16a42c0c708f914021666ffcd8265dde36e673c9fa68c81f7d085d9774ad" + url: "https://pub.dev" + source: hosted + version: "0.8.13+3" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "86f0f15a309de7e1a552c12df9ce5b59fe927e71385329355aec4776c6a8ec91" + url: "https://pub.dev" + source: hosted + version: "0.2.2+1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" + url: "https://pub.dev" + source: hosted + version: "2.11.1" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae + url: "https://pub.dev" + source: hosted + version: "0.2.2" + jni: + dependency: transitive + description: + name: jni + sha256: "8706a77e94c76fe9ec9315e18949cc9479cc03af97085ca9c1077b61323ea12d" + url: "https://pub.dev" + source: hosted + version: "0.15.2" leak_tracker: dependency: transitive description: @@ -114,6 +303,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: @@ -138,6 +335,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: f8872ea6c7a50ce08db9ae280ca2b8efdd973157ce462826c82f3c3051d154ce + url: "https://pub.dev" + source: hosted + version: "0.17.2" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: c12701c978eacda8d8a9be1469f005e26bf16a903945982b94f77d7a9dbeea45 + url: "https://pub.dev" + source: hosted + version: "9.2.1" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" path: dependency: transitive description: @@ -154,6 +383,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" sky_engine: dependency: transitive description: flutter @@ -207,6 +444,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.7" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" vector_math: dependency: transitive description: @@ -223,6 +468,22 @@ packages: url: "https://pub.dev" source: hosted version: "15.0.2" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" sdks: dart: ">=3.10.0 <4.0.0" - flutter: ">=3.35.0" + flutter: ">=3.35.6" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 191907d..d404281 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,98 +1,24 @@ name: image_ffi_example description: "Demonstrates how to use the image_ffi plugin." -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. +publish_to: 'none' version: 1.0.0+1 environment: sdk: ^3.10.0 flutter: '>=3.35.0' -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter image_ffi: - # When depending on this package from a real application you should use: - # image_ffi: ^x.y.z - # See https://dart.dev/tools/pub/dependencies#version-constraints - # The example app is bundled with the plugin so we use a path dependency on - # the parent directory to use the current plugin's version. path: ../ - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.8 + image_picker: dev_dependencies: flutter_test: sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^6.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/to/resolution-aware-images - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/to/asset-from-package - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/to/font-from-package From aa0f5b0fdcba377c40c06cacd1d2500a5fc45ee3 Mon Sep 17 00:00:00 2001 From: Koji Wakamiya Date: Mon, 8 Dec 2025 11:07:00 +0900 Subject: [PATCH 3/3] doc: README --- README.md | 179 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 95f3582..33e5ab1 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,139 @@ # image_ffi -A new Flutter FFI plugin project. +A high-performance Flutter plugin for cross-platform image format conversion using native APIs. + +## Features + +- 🖼️ **Versatile Format Conversion**: Supports conversion between JPEG, PNG, and WebP. It also handles HEIC/HEIF, allowing conversion *from* HEIC on all supported platforms and *to* HEIC on iOS/macOS. +- ⚡ **Native Performance**: Achieves high speed by using platform-native APIs directly: ImageIO on iOS/macOS and BitmapFactory on Android. +- 🔒 **Efficient Native Interop**: Employs FFI and JNI to create a fast, type-safe bridge between Dart and native code, ensuring robust and reliable communication. + +## Platform Support + +| Platform | Minimum Version | API Used | +|----------|-----------------|----------| +| iOS | 14.0 | ImageIO (CoreFoundation, CoreGraphics) | +| macOS | 10.15 | ImageIO (CoreFoundation, CoreGraphics) | +| Android | 7 | BitmapFactory, Bitmap compression | +| Web | N/A | Not supported | + +on Android, HEIC input is supported on Android 9+ but HEIC output is not supported. ## Getting Started -This project is a starting point for a Flutter -[FFI plugin](https://flutter.dev/to/ffi-package), -a specialized package that includes native code directly invoked with Dart FFI. +### Installation -## Project structure - -This template uses the following structure: - -* `src`: Contains the native source code, and a CmakeFile.txt file for building - that source code into a dynamic library. - -* `lib`: Contains the Dart code that defines the API of the plugin, and which - calls into the native code using `dart:ffi`. - -* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files - for building and bundling the native code library with the platform application. - -## Building and bundling native code - -The `pubspec.yaml` specifies FFI plugins as follows: +Add `image_ffi` to your `pubspec.yaml`: ```yaml - plugin: - platforms: - some_platform: - ffiPlugin: true +dependencies: + image_ffi: ^0.0.1 ``` -This configuration invokes the native build for the various target platforms -and bundles the binaries in Flutter applications using these FFI plugins. +### Basic Usage -This can be combined with dartPluginClass, such as when FFI is used for the -implementation of one platform in a federated plugin: +```dart +import 'package:image_ffi/image_ffi.dart'; +import 'dart:typed_data'; -```yaml - plugin: - implements: some_other_plugin - platforms: - some_platform: - dartPluginClass: SomeClass - ffiPlugin: true +// Convert HEIC image to JPEG +final jpegData = await ImageConverter.convert( + inputData: heicImageData, + format: OutputFormat.jpeg, + quality: 90, +); + +// Convert any format to PNG +final pngData = await ImageConverter.convert( + inputData: imageData, + format: OutputFormat.png, +); ``` -A plugin can have both FFI and method channels: +## Supported Formats -```yaml - plugin: - platforms: - some_platform: - pluginClass: SomeName - ffiPlugin: true +### Input Formats +- **iOS/macOS**: JPEG, PNG, HEIC, WebP, BMP, GIF, TIFF, and more +- **Android**: JPEG, PNG, WebP, GIF, BMP, HEIC (via BitmapFactory) + +### Output Formats +The supported output formats are defined by the `OutputFormat` enum, with platform-specific limitations: +- **JPEG**: Supported on all platforms. +- **PNG**: Supported on all platforms. +- **WebP**: Supported on Android only. +- **HEIC**: Supported on iOS/macOS only. + +## API Reference + +### `ImageConverter.convert()` + +```dart +static Future convert({ + required Uint8List inputData, + OutputFormat format = OutputFormat.jpeg, + int quality = 100, +}) async ``` -The native build systems that are invoked by FFI (and method channel) plugins are: +**Parameters:** +- `inputData` (`Uint8List`): Raw image data to convert +- `format` (`OutputFormat`): Target image format (default: JPEG) +- `quality` (`int`): Compression quality 1-100 (default: 100, only for lossy formats) -* For Android: Gradle, which invokes the Android NDK for native builds. - * See the documentation in android/build.gradle. -* For iOS and MacOS: Xcode, via CocoaPods. - * See the documentation in ios/image_ffi.podspec. - * See the documentation in macos/image_ffi.podspec. -* For Linux and Windows: CMake. - * See the documentation in linux/CMakeLists.txt. - * See the documentation in windows/CMakeLists.txt. +**Returns:** `Future` containing the converted image data -## Binding to native code +**Throws:** +- `UnsupportedError`: If the platform or format is not supported +- `Exception`: If conversion fails -To use the native code, bindings in Dart are needed. -To avoid writing these by hand, they are generated from the header file -(`src/image_ffi.h`) by `package:ffigen`. -Regenerate the bindings by running `dart run ffigen --config ffigen.yaml`. +### `OutputFormat` Enum -## Invoking native code +```dart +enum OutputFormat { + /// JPEG format (.jpg, .jpeg) + /// Lossy compression, suitable for photos + jpeg, -Very short-running native functions can be directly invoked from any isolate. -For example, see `sum` in `lib/image_ffi.dart`. + /// PNG format (.png) + /// Lossless compression, supports transparency + png, -Longer-running functions should be invoked on a helper isolate to avoid -dropping frames in Flutter applications. -For example, see `sumAsync` in `lib/image_ffi.dart`. + /// WebP format (.webp) + /// Modern format with superior compression (not supported on Darwin) + webp, -## Flutter help + /// HEIC format (.heic) + /// High Efficiency Image Format (not supported on Android) + heic, +} +``` -For help getting started with Flutter, view our -[online documentation](https://docs.flutter.dev), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +## Implementation Details +### iOS/macOS Implementation + +The iOS/macOS implementation uses the [ImageIO](https://developer.apple.com/documentation/imageio) framework via FFI bindings: + +1. **Decoding**: `CGImageSourceCreateWithData` reads input data +2. **Rendering**: `CGImageSourceCreateImageAtIndex` decodes to `CGImage` +3. **Encoding**: `CGImageDestinationCreateWithData` encodes to target format +4. **Quality**: Uses `kCGImageDestinationLossyCompressionQuality` for JPEG/WebP + +**Key Functions:** +- `CFDataCreate`: Create immutable data from input bytes +- `CGImageSourceCreateWithData`: Create image source from data +- `CGImageDestinationCreateWithData`: Create image destination +- `CGImageDestinationAddImage`: Add image to destination +- `CGImageDestinationFinalize`: Complete encoding + +### Android Implementation + +The Android implementation uses [BitmapFactory](https://developer.android.com/reference/android/graphics/BitmapFactory) and [Bitmap.compress](https://developer.android.com/reference/android/graphics/Bitmap#compress(android.graphics.Bitmap.CompressFormat,%20int,%20java.io.OutputStream)): + +1. **Decoding**: `BitmapFactory.decodeByteArray` handles all supported formats +2. **Compression**: `Bitmap.compress` encodes to target format +3. **Buffer Management**: `ByteArrayOutputStream` manages output data + +**Key Limitations:** +- HEIC can be read (input only) but cannot be written (output format not supported) +- Requires Android 9+ for full HEIC support