Jump to content

8-bit Image Save as a new file without any editing, the Data are all changed


Go to solution Solved by MJW,

Recommended Posts

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 by kvusnnh
Help clarify my question
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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 by kvusnnh
Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Solution
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...