FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 4.6.2 x86_64 Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz GenuineIntel GNU/Linux
A DESCRIPTION OF THE PROBLEM :
BufferedImage created from SwingFXUtils does not correspond fully to source FXImage. Some meta-information seems to be missing. It is lead to storing incorrectly painted image file with ImageIO.write
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create new javafx.scene.image.WritableImage
2. Fill its content with getPixelWriter.setPixels
3. Convert using SwingFXUtils.fromFXImage
4. Save to the jpg file
That is the recommended way to save javafx image to a file: https://community.oracle.com/thread/2450090?tstart=0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jpg file that contains image
ACTUAL -
result image has Green and Blue channels degraded (as if each pixel is multiplied by 0.5)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
I does not know Java language. Could share code in Scala
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The interesting thing is that in some cases swingutils creates correct BufferImage that saves to correct jpg file. Change the reproduce sequence to the following and you will get expected result.
1. Load file from disk into WritableImage
2. Convert using SwingFXUtils.fromFXImage
3. Save to the jpg file
Now created file contains all color channels unchanged.
If you still need to create empty JavaFX image, fill it, and write to a file, then you should use other image format to store file. PNG is ok.
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 4.6.2 x86_64 Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz GenuineIntel GNU/Linux
A DESCRIPTION OF THE PROBLEM :
BufferedImage created from SwingFXUtils does not correspond fully to source FXImage. Some meta-information seems to be missing. It is lead to storing incorrectly painted image file with ImageIO.write
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create new javafx.scene.image.WritableImage
2. Fill its content with getPixelWriter.setPixels
3. Convert using SwingFXUtils.fromFXImage
4. Save to the jpg file
That is the recommended way to save javafx image to a file: https://community.oracle.com/thread/2450090?tstart=0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jpg file that contains image
ACTUAL -
result image has Green and Blue channels degraded (as if each pixel is multiplied by 0.5)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
I does not know Java language. Could share code in Scala
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The interesting thing is that in some cases swingutils creates correct BufferImage that saves to correct jpg file. Change the reproduce sequence to the following and you will get expected result.
1. Load file from disk into WritableImage
2. Convert using SwingFXUtils.fromFXImage
3. Save to the jpg file
Now created file contains all color channels unchanged.
If you still need to create empty JavaFX image, fill it, and write to a file, then you should use other image format to store file. PNG is ok.
- duplicates
-
JDK-8129747 SwingFXUtils.fromFXImage seems to have a bug inside
-
- Resolved
-