graphx icon indicating copy to clipboard operation
graphx copied to clipboard

Color Palette Error

Open dafep opened this issue 2 years ago • 8 comments

Future<ByteData?> getImageBytes(GDisplayObject object) async { var texture = await object.createImageTexture(); <--------- Here return texture.root?.toByteData(); // texture?.dispose(); // texture = null; }

[ +95 ms] [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Invalid image dimensions. [ ] #0 Picture.toImage (dart:ui/painting.dart:5791:7) [ ] #1 GDisplayObject.createImage (package:graphx/src/display/display_object.dart:1132:34) [ ] #2 GDisplayObject.createImageTexture (package:graphx/src/display/display_object.dart:1099:23) [ ] #3 getImageBytes (package:neuron/widgets/studio/components/right_menu/atomic_ui/color_palette_utils.dart:35:30) [ ] #4 HueScene.addedToStage (package:neuron/widgets/studio/components/right_menu/atomic_ui/color_palette_hue_scene.dart:108:5) [ ] #5 GDisplayObjectContainer.addChildAt (package:graphx/src/display/display_object_container.dart:152:15)

dafep avatar Mar 24 '23 00:03 dafep

This is a port of the ColorPicker example?

Could you try the graphx version on Github? Follow this guide.

Are you testing on desktop/web/mobile ?

roipeker avatar Mar 24 '23 00:03 roipeker

Yes I'm talking about ColorPicker, I'm currently using it on the Desktop with Graphx version 1.0.9

dafep avatar Mar 24 '23 00:03 dafep

I just tried it on macos, and seems to be working on the master channel, which flutter version are you using?

roipeker avatar Mar 24 '23 00:03 roipeker

Is kinda late for me now. To get more prompt and interactive support, I encourage you to join us on our Telegram or Discord channels, you can get the links in the readme.

I will be available tomorrow to provide further assistance if needed. Looking forward to seeing you there and helping you resolve your issue.

roipeker avatar Mar 24 '23 00:03 roipeker

I'm on version 3.9.0-16.0.pre.37 on the channel master I copied the ColorPicker project exactly as it is on GitHub without any difference, and I have the error I showed you

Flutter 3.9.0-16.0.pre.37 • channel master • https://github.com/flutter/flutter.git Framework • revision f80a7a24db (15 hours ago) • 2023-03-23 20:09:44 -0400 Engine • revision 1da070c57c Tools • Dart 3.0.0 (build 3.0.0-362.0.dev) • DevTools 2.22.2

dafep avatar Mar 24 '23 14:03 dafep

I'm on macOS, can't test on Windows/Linux Using latest master channel now (3.9.0-16.0.pre.42)

in pubspec.yaml

environment:
#  sdk: ">=2.19.0 <3.0.0"
  sdk: ">=3.0.0-362.0.dev <=4.0.0"

I can run the example without exceptions. Maybe something was wrong on the master channel in a previous release or I modified the code of the sample... Try to run the latest example from the repo please, and let me know if it works.

The exception you shown seems like a dimension issues to rasterize the Picture to Image, so maybe the boundries are not detected... something like width or height <=0 or nan or infinite.

As a quick test, run this code as your scene, and see if it renders a magenta circle (this uses the same API as the color picker demo to rasterize an Image):

class SampleTexture extends GSprite {
  @override
  Future<void> addedToStage() async {
    stage!.addChild(
      GBitmap(await GTextureUtils.createCircle()),
    );
  }
}

roipeker avatar Mar 24 '23 15:03 roipeker

I have well the round of magenta color which is displayed with the piece of code that you write

dafep avatar Mar 24 '23 15:03 dafep

Then most likely is an issue with dimensions. Probably the widget is not being expanded and the stage size is 0.

Test the latest code from the repo and tell me if the issue persist.

Also, as suggested before, you can join us in our server for further help, as I can't replicate this issue.

roipeker avatar Mar 24 '23 15:03 roipeker