Codenameone Image 24 Bit PNG

Viewed 50

i have a question to work with pictures in Codenameone (my Code works,I just want to ask if there is a better way)

(don't really know how to call the title because it's really specific)

at the end i want to get a 24Bit non compressed image (so i picked PNG)

  1. i have an Image(Image1 JPG) selected by the user that i scale down/up dynamicaly(with the normal scale method)
  2. i crate a copy of the image with EncodedImage.create(width,height) so its mutable --> Image2
  3. i draw Image1 on Image2
  4. i set Image1 to null (don't need it anymore)
  5. i draw an watermark on Image2 (needs to be drawn before step 6)
  6. i get pixels = Image2.getRGBCached() because i modify a lot of pixel values
  7. i set Image2 to null
  8. i modify the pixel values
  9. i call EncodedImage.create(pixels,width,height) --> Image3 (if i save Image3 it's 32Bit PNG)
  10. i create a copy of image 3 with EncodedImage.create(width,height) --> image4
  11. i draw Image3 on Image4
  12. save Image4 --> output = 24Bit PNG

maybe can i open an Image that is directly mutable or save image 3 as 24 Bit PNG directly?

Thanks

Marcus

1 Answers

We don't support complex image encoding attributes and I'm not sure if they're supported by the underlying platforms. However, we do give you access to all the integer RGB values of the image itself so you can manually encode an uncompressed PNG or BMP.

I'm not sure why you would need that specific format though since PNG compressed or otherwise is lossless AFAIK.

Related