kvusnnh Posted December 6, 2022 Share Posted December 6, 2022 (edited) Hello, I uesd the paint.net to load an 8-bit image (called it A). And save it as a new 8-bit image file (called it B). The look of these two are seem the same. But after I read the hex data of them, their data are not the same. For example, the offsetvalue (10th byte) of A is 1078, but 474 for B. And after reading all the bitmap data and show them on my own tool. The B's picture is more darker than the A one. Can anyone tell me why there's a difference after saving image without any editing? Thank you very much. Edited December 16, 2022 by kvusnnh Help clarify my question Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted December 6, 2022 Share Posted December 6, 2022 20 minutes ago, kvusnnh said: Can anyone tell me why there's a difference after saving image without any editing? Are you a filetype that uses lossless compression? Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
kvusnnh Posted December 6, 2022 Author Share Posted December 6, 2022 (edited) Hello toe_head2001, These images are all Bitmap filetype . Thank you very much. Edited December 16, 2022 by kvusnnh Quote Link to comment Share on other sites More sharing options...
MJW Posted December 6, 2022 Share Posted December 6, 2022 50 minutes ago, kvusnnh said: I uesd the paint.net to load an 8-bit image (called it A). And save it as a new 8-bit image file (called it B). I'm not sure that's unexpected. When PDN loads an image, 8-bit or whatever, it's converted to 32-bit ARGB. When an image is saved as an 8-bit image, the 32 bit full-color image is converted, using some algorithm, into 8-bits. I don't think there's much expectation or likelihood that the saved file's hex values will match the original values. I'm a little confused by your saying the two images look the same, but later saying that B is darker than A when using you own tool. The question I have is whether the images are identical in PDN. If they are, the question is whether they're identical when viewed with some other program -- besides your own program -- such as MS Paint (or whatever is nowadays). Quote Link to comment Share on other sites More sharing options...
kvusnnh Posted December 6, 2022 Author Share Posted December 6, 2022 (edited) Hello MJW, Sorry for the unclear description. I mean the preview icon of these two images look the same. But when use my own tool(MFC tool) to load the bitmap data into a buffer and then show on my picture control item. It looks more darker than loading the original one. Again, I apology for the unclear description... Thank you very much. Edited December 16, 2022 by kvusnnh Quote Link to comment Share on other sites More sharing options...
MJW Posted December 6, 2022 Share Posted December 6, 2022 Since the images appear the same, yet your tool shows them to be much different, I suggest that there may be a problem with your tool. Specifically, I wonder if you're property applying the the color table, or if perhaps you're incorrectly assuming the colors in the table will be arranged in some particular order. (To get the color from an 8-bit Bitmap image, you must use the 8-bit color value as an index into the color table (aka, Palette), which contains 256 32-bit colors.) Quote Link to comment Share on other sites More sharing options...
kvusnnh Posted December 6, 2022 Author Share Posted December 6, 2022 Hello MJW, Although the two images seem to be the same ,data of these two are not the same when I print out the log at the same location of the buffer like : data[100], data[1000], data[1500]...etc. It does confuse me at this part... It's all before the function to show the segmeation images on the tool. But I will chek my code. Thank you very much. Quote Link to comment Share on other sites More sharing options...
Solution MJW Posted December 6, 2022 Solution Share Posted December 6, 2022 On 12/6/2022 at 1:40 AM, kvusnnh said: data of these two are not the same when I print out the log at the same location of the buffer like The data may be incorrect because you're not doing the indexing correctly. Two 8-bit Bitmap files can be functionally identical (i.e., will produce the same image) but completely different internally if the colors in the color table are in different orders. There is no right or wrong order for the color table entries, so to process an 8-bit Bitmap file, you must use the 8-bit values as indices into the color table. The color table (a property called Palette) contains an array of Colors (called Entries). The 8-bit color values are used to index into that array to fetch the ARGB color that corresponds to the value. EDIT: Let me say it in a slightly different way, that may be clearer. If the 8-bit color is, for instance, 20, that doesn't mean it's the 20th level of brightness or anything like that. It means it's the 20th color in the color table. To find out what that color is, you must index into the table. Quote Link to comment Share on other sites More sharing options...
kvusnnh Posted December 6, 2022 Author Share Posted December 6, 2022 Hi MJW, Thank you for your advice. I'll check if it's the color issue in my code. Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.