newImageRect doesn't show proper color

Hi, currently I have been working on school project, and decided to do it in Solar2D. Basically it is steganography, I am trying to cipher text into image, and later also retrieve it. The algorithm itself already works however I noticed there is one issue with newImageRect (or newImage, tried both, both have the same issue).

I noticed that when creating image object, solar changes the rgb values of this object. For example amount of red in certain pixel in original image is 102 (out of 255), but in Solar it becomes 98. It doesn’t look too diferent, however for algorithm to work properly, the values need to be exact.

I also noticed that the image get a little bit smoother, and less pixelated in Solar. Generally that would be great, but for this problem I need the image to stay pixelated and show exact colors.

I think maybe because the image in Solar program is with smooth edges, it seems that one pixel doesn’t have uniform color anymore, and its edges are tinted, to look smother. And perhaps the color of that pixel then is some interpolation of the colors “within the pixel”.

In summary is there a way to get just the image (doesn’t even have to be display object) with exact original rgb values?

Best regards,
Marek

You can try setting the following before loading the image:

display.setDefault( “minTextureFilter”, “nearest” )
display.setDefault( “magTextureFilter”, “nearest” )

Edit:
If you’re using display.colorSample to get the values then you’ll definitely need a display object.

I think the only other alternative is to read the image file with the lfs library, but you’ll need to decode the image format to get the values you need.

1 Like

Thank you so much for quick reply and helping me with the issue. You were right with the texture filters, it does work properly now. I do not know why it didn’t cross my mind, however I am glad it works (at least for now).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.