首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >I/OpenJPEG(18753):[INFO]没有解码区域参数,将解码区域设置为整个图像。如何解决这个问题?

I/OpenJPEG(18753):[INFO]没有解码区域参数,将解码区域设置为整个图像。如何解决这个问题?
EN

Stack Overflow用户
提问于 2022-05-25 15:23:35
回答 1查看 98关注 0票数 0

我在我的颤振项目中添加了一些本机函数,并在调用它时得到了这个错误:

代码语言:javascript
复制
I/OpenJPEG(18753): [INFO] Start to read j2k main header (111).
I/OpenJPEG(18753): [INFO] Main header has been correctly decoded.
I/OpenJPEG(18753): [INFO] No decoded area parameters, set the decoded area to the whole image
I/OpenJPEG(18753): [INFO] Header of tile 1 / 1 has been read.
I/OpenJPEG(18753): [INFO] Stream reached its end !


 PlatformException(error, Unsupported value: 'android.graphics.Bitmap@8a5b1cc' of type 'class android.graphics.Bitmap', null, java.lang.IllegalArgumentException: Unsupported value
: 'android.graphics.Bitmap@8a5b1cc' of type 'class android.graphics.Bitmap'
I/flutter (20654):      at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:292)
I/flutter (20654):      at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:59)
I/flutter (20654):      at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:267)
I/flutter (20654):      at com.yapeal.security.MainActivity.convertJp2(MainActivity.kt:163)
I/flutter (20654):      at com.yapeal.security.MainActivity.configureFlutterEngine$lambda-0(MainActivity.kt:70)
I/flutter (20654):      at com.yapeal.security.MainActivity.lambda$Sgujey3khZ1hmf7McHG_B6lCGlU(Unknown Source:0)
I/flutter (20654):      at com.yapeal.security.-$$Lambda$MainActivity$Sgujey3khZ1hmf7McHG_B6lCGlU.onMethodCall(Unknown Source:2)
I/flutter (20654):      at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.j

这是我在Kotlin的代码:

代码语言:javascript
复制
private fun convertJp2(list: List<Any>, result: MethodChannel.Result) {
        val inputStream: InputStream = ByteArrayInputStream(list.get(0) as ByteArray, 0, list.get(1) as Int)

        var image = JP2Decoder(inputStream).decode()
        result.success(image)
    }

我对Kotlin没有经验,所以我不知道如何解决这个问题。此外,我在谷歌也没有发现类似的问题……

EN

回答 1

Stack Overflow用户

发布于 2022-05-27 10:06:42

StandardMessageCodec是由MethodChannel使用的,它不支持开箱即用Bitmap (https://api.flutter.dev/flutter/services/StandardMessageCodec-class.html)。

您可以扩展StandardMessageCodec并覆盖writeValue以支持它(https://docs.flutter.dev/development/platform-integration/platform-channels#custom-channels-and-codecs)

下面是一个cloud_firestore如何使用自己的编解码器来扩展功能的示例:https://github.com/firebase/flutterfire/blob/master/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/utils/firestore_message_codec.dart

代码语言:javascript
复制
  @override
  void writeValue(WriteBuffer buffer, dynamic value) {
    if (value is DateTime) {
      buffer.putUint8(_kDateTime);
      buffer.putInt64(value.millisecondsSinceEpoch);
    } else if (value is Timestamp) {
      buffer.putUint8(_kTimestamp);
      buffer.putInt64(value.seconds);
      buffer.putInt32(value.nanoseconds);
    } else if (value is GeoPoint) {
      buffer.putUint8(_kGeoPoint);
      buffer.putFloat64(value.latitude);
      buffer.putFloat64(value.longitude);
    } else if (value is DocumentReferencePlatform) {
      buffer.putUint8(_kDocumentReference);
      writeValue(buffer, value.firestore);
      writeValue(buffer, value.path);
    } else if (value is Blob) {
      buffer.putUint8(_kBlob);
      writeSize(buffer, value.bytes.length);
      buffer.putUint8List(value.bytes);
    } else if (value is FieldValuePlatform) {
      MethodChannelFieldValue delegate = FieldValuePlatform.getDelegate(value);
      final int code = _kFieldValueCodes[delegate.type]!;
      buffer.putUint8(code);
      if (delegate.value != null) writeValue(buffer, delegate.value);
    } else if (value is FieldPathType) {
      final int code = _kFieldPathCodes[value]!;
      buffer.putUint8(code);
    } else if (value is FieldPath) {
      buffer.putUint8(_kFieldPath);
      writeSize(buffer, value.components.length);
      for (final String item in value.components) {
        writeValue(buffer, item);
      }
    } else if (value is MethodChannelFirebaseFirestore) {
      buffer.putUint8(_kFirestoreInstance);
      writeValue(buffer, value.app.name);
      writeValue(buffer, value.settings);
    } else if (value is MethodChannelQuery) {
      buffer.putUint8(_kFirestoreQuery);
      writeValue(buffer, <String, dynamic>{
        'firestore': value.firestore,
        'path': value.path,
        'isCollectionGroup': value.isCollectionGroupQuery,
        'parameters': value.parameters,
      });
    } else if (value is Settings) {
      buffer.putUint8(_kFirestoreSettings);
      writeValue(buffer, value.asMap);
    } else if (value == double.nan) {
      buffer.putUint8(_kNaN);
    } else if (value == double.infinity) {
      buffer.putUint8(_kInfinity);
    } else if (value == double.negativeInfinity) {
      buffer.putUint8(_kNegativeInfinity);
    } else {
      super.writeValue(buffer, value);
    }
  }

用途类似:https://github.com/firebase/flutterfire/blob/982bdfb5fbfae4a68e1af6ab62a9bd762891b217/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/method_channel_firestore.dart

代码语言:javascript
复制
  /// The [FirebaseApp] instance to which this [FirebaseDatabase] belongs.
  ///
  /// If null, the default [FirebaseApp] is used.
  /// The [MethodChannel] used to communicate with the native plugin
  static MethodChannel channel = const MethodChannel(
    'plugins.flutter.io/firebase_firestore',
    StandardMethodCodec(FirestoreMessageCodec()),
  );

  /// The [EventChannel] used for query snapshots
  static EventChannel querySnapshotChannel(String id) {
    return EventChannel(
      'plugins.flutter.io/firebase_firestore/query/$id',
      const StandardMethodCodec(FirestoreMessageCodec()),
    );
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72380374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档