Closed refaelsh closed 1 year ago
I can check it when I review the PR.
Can you please? I am kinda lazy on that regard :-)
On line 383, I don't really know the correct numbers. Do you?
Those numbers are really important! They indicate the format in which the color data is encoded. According to the documentation, the numbers you used are saying that the bytes you are providing are in the RGB8 format and are describing a 16x16 image.
I'd give an example, but 16x16 is a lot, so let's simplify and pretend you are describing a 2x2 image whose pixels are red at the top-left, grey at the top-right, white at the bottom-left, and white at the bottom-right. In hex, those 3 colours are:
You would thus need to provide those 12 bytes:
FF 00 00 88 88 88 FF FF FF FF FF FF
Are those the bytes you are providing? Not at all! You have loaded the bytes of a png file into memory, but a png is not stored as an array of RGB8 pixels. For one thing, it starts with magic numbers indicating that the file is a png, and then a header indicating the size of the file and some other metadata, and the compressed color data.
I would again provide an example, but the real png format is really complicated, so let's just pretend like the png format for that 2x2 image looks like this:
PNG
2 2
1 FF0000
1 888888
2 FFFFFF
That is, this is a PNG
, the image has size 2x2
, the first 1 pixels have color FF0000
, the next 1 pixels have color 888888
, the next 2 pixels have color FFFFFF
.
In hex, "PNG" is 50 4E 47, so the png file consists of the following bytes:
50 4E 47 02 02 01 FF 00 00 01 88 88 88 02 FF FF FF
You are interpreting those bytes as color values, so the first 12 bytes will be interpreted as four seemingly-random colors:
I recommend using the JuicyPixels library to load the png into the RGB8 format.
Yes, I understand. Thank you very much for the explanation. I will need some time to process it all, but I think I understand.
I recommend using the JuicyPixels library to load the png into the RGB8 format.
I will go and read the documentation of this right now.
@gelisam Great explanation, thanks a lot for that!
I did another commit that is code review quality.
@refaelsh Sorry it took my a while to get to this!
Here's my understanding the current status of this:
master
), nor this PR appear to set the application icon correctly. So it appears that this PR is at least not making things worse.Is that correct? If so, I'll have to put together a GTK3-based Gnome environment and confirm that this PR correctly sets the application icon.
Sorry it took my a while to get to this!
That's perfectly ok! All is fine :-)
Is that correct?
Yes.
@gelisam has tested this PR in a GTK4-based Gnome environment,
I'm using Gnome version 42.4; I have no idea whether that version is based on GTK3 or GTK4.
@gelisam has tested this PR in a GTK4-based Gnome environment,
I'm using Gnome version 42.4; I have no idea whether that version is based on GTK3 or GTK4.
Interesting question. Google did not help me here, not a definite answer any way. Best guess: GTK4.
I took a look at the icon from this PR in the VM added in #230, and while it does appear that the icon is getting set, it looks like it is not rendering correctly:
You can see it in the title bar here:
And a larger image here?
Maybe there is some way you could easily write the final PixBuf
to a file, and use that for debugging?
@cdepillabout Thank you for checking it in a VM!
Maybe there is some way you could easily write the final PixBuf to a file, and use that for debugging?
Good suggestion. I will do it and ping back here when its done.
Good suggestion. I will do it and ping back here when its done.
I did it. There is a file with an icon that is created. It looks ugly, but it exists --> I assume that all the shenanigans with converting to this Pixbuf
thingy works. Again, the icon comes out distorted, but it's there. I am attaching the resulting file.
The fact that it is distorted means that the numbers are incorrect. For example, maybe the image has 4 bytes per pixel and you're interpreting them as 3 bytes per pixel. So if the original image is
<red> <red> <red>
<red> <blue> <red>
<red> <red> <red>
and each pixel is encoded as 4 bytes, so each row has 3 groups of 4 bytes:
[FF 00 00 FF] [FF 00 00 FF] [FF 00 00 FF]
[FF 00 00 FF] [00 00 FF FF] [FF 00 00 FF]
[FF 00 00 FF] [FF 00 00 FF] [FF 00 00 FF]
But you incorrectly interpret each row as 4 groups of 3 bytes:
[FF 00 00] [FF FF 00] [00 FF FF] [00 00 FF]
[FF 00 00] [FF 00 00] [FF FF FF] [00 00 FF]
[FF 00 00] [FF FF 00] [00 FF FF] [00 00 FF]
Then you end up with an image which looks kind of like the original, but with weird vertical color bands:
<red> <yellow> <turquoise> <blue>
<red> <red> <white> <blue>
<red> <yellow> <turquoise> <blue>
@gelisam Thank you very much, this helps. I will indeed continue working to make the image not distorted.
Short status update: I've managed to improve the distortion in the icon, it looks like this now: The colors are a bit off, and it appears to be flipped vertically.
I will continue working on this.
Short update: I fixed the horizontal flip. The image looks now identical to the original. The code is not ready for review. I will continue working on it.
The code is ready. @cdepillabout, Can you please verify the fix via your VM method?
I am now noticing that my formatter made a lot of changes. I use what comes by default with GHC and/or haskell-language-server. What do you use?
Can you please verify the fix via your VM method?
Sure, I can do this, but I probably won't have any time for at least the next 3 weeks. I'll get back to you again after I have time to test this out.
I am now noticing that my formatter made a lot of changes. I use what comes by default with GHC and/or haskell-language-server. What do you use?
I actually don't use a formatter on the Termonad codebase. My personal style is somewhat similar to the default style in hindent
, but enough people have worked on the Termonad codebase now that different sections have slightly different formatting styles.
I may ask you to remove the formatting-specific changes in this PR (so that it is easier to just see the code you have added), but you could always just do that after I confirm in the VM.
Sure, I can do this
Thank you very much :-)
but I probably won't have any time for at least the next 3 weeks
Sure. No problem. What's best for you.
but you could always just do that after I confirm in the VM.
Yes. Understood and agreed.
@cdepillabout Can I please bother you for a minute of your time? Please go and upvote/+1/like this question: https://github.com/xmonad/xmonad/discussions/472. If there is an answer, it might save the whole VM time spin up in the future.
I was able to test this, it is looking good!
Here are shots from the VM:
You can see the icon is looking correct!
@refaelsh Could you rebase this on master
, and get rid of the formatting changes? After you do that, I'll merge this in!
@refaelsh Could you rebase this on master
Sure. No problem.
and get rid of the formatting changes
Off course. I am on it.
I did something wrong. I am not really sure what. Not only that, but I've done many rebases in my life but never on a forked repo. I will close this PR and open a new one. I don't see any other choice. Is that ok by you?
@refaelsh Yeah, no problem!
I've created a new PR in continues of this: https://github.com/cdepillabout/termonad/pull/227.