c++ - SDL2 / SDL Image strange PNG behavior with RGB values -
I have found an interesting thing that I am not able to debug but I want to solve because it is for development Important I need a small device.
Actually, all reduce the fact that I have a PNG load in SDL_Surface
IMG_Load ("filename.png")
. The skeleton of the code is
surface = IMG_Load ("filename.png");
Then apply this tool to pixels by a pixel by implementing a color map (which is a unordered_map
) Should copy. It works basically, but there are slight changes in the RGB values of several pixels, so this replacement fails. For example, when a pixel 255,255,255 is correctly stored in the form of 0xFFFFFFFF in the surface, another pixel, let's become 81, 60,48 82,62,51, I thought of gamma correction, but the image itself Because the color switch is applied before two surfaces, and later pulled on any texture.
Any clues? I am not interested in finding a second solution to my problem because I should be able to make accurate pixel color switching with a certain map, I should understand why this is happening (because PNG should have accurate value Lossless) And solve it.
OK, I got the reason and the problem that was fixed is how PNG OS X frameworks Is loaded through. According to the thread, it is related to the image, which is taken in any way while loading the image. The following is proposed:
CGFLot whitepoint [3] = {1, 1, 1}; CGFloat Black Point [3] = {0, 0, 0}; CGFloat Gamma [3] = {2.2, 2.2, 2.2}; CGFloat matrix [9] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; CGColorSpaceRef color_space = CGColorSpaceCreateCalibratedRGB (white point, blackpoint, gamma, matrix); I was surprised by imageIO.m
SDL_Image
and it was resolved by reconfiguring it from source sources. That is why it has not been included in SDL_Image (or, rather, only one version with custom values).
Comments
Post a Comment