Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wintc-taskband support for other themes (Royale + Royale Noir, Zune, etc) #352

Open
enderman0125 opened this issue Sep 12, 2024 · 20 comments
Assignees
Labels
question Further information is requested

Comments

@enderman0125
Copy link

Any possibility of updating wintc-taskband to support other themes in the pack such as Royale Noir and Zune? It looks a bit out of place when I have Royale Noir applied but the taskbar is the regular blue Luna theme. Is this planned in the future?

@rozniak rozniak self-assigned this Sep 13, 2024
@rozniak rozniak added the question Further information is requested label Sep 13, 2024
@rozniak
Copy link
Owner

rozniak commented Sep 13, 2024

See the additional-theme label: additional-theme New theme needs implementing

At the moment only the XFWM4 decorations are present for those other themes, the GTK stuff isn't done yet.

@enderman0125
Copy link
Author

Ah, alright.

@acdavit
Copy link

acdavit commented Oct 30, 2024

I'm wondering if it's possible to make an automated script that would take preexisting XP themes and convert them to something that both XFCE4 and winxp-tc could use, There are like thousands of unofficial Windows XP themes floating around on the internet that I would love to use on my XP-fied Linux installation

To what extent are the bitmaps from the original Windows XP themes altered? Would it even be possible to do something similar to this or would there be too much voodoo involved?

@rozniak
Copy link
Owner

rozniak commented Oct 30, 2024

@acdavit I have thought about that for quite some time, I think the last time I commented on the idea was in #222 . I did recently start toying around with it in a branch ft-uxtheme, essentially all that's there at the moment is the beginnings of a Python tool for extracting the theme resources as a test. Trouble I came across instantly was that PIL/Pillow does not correctly support 32bpp bitmaps (used by some theme parts like the radio button). I didn't really feel like faffing with parsing the BITMAPV3 headers or whatever manually right now so it's left where it is - if you know some Python and feel like chipping in there it would be useful.

For the time being though I figured it would be best to get the themes done the same way as I have done Luna (Blue) and Professional, just so that there's at least something rather than nothing.

I should probably write my thoughts on what might be needed in a separate issue. Just in general a good start would be getting the resources extracted correctly without losing the alpha channel from the 32bpp bitmaps.

@acdavit
Copy link

acdavit commented Nov 17, 2024

@rozniak

Do you mind if I post a question about it on stack overflow?

@rozniak
Copy link
Owner

rozniak commented Nov 17, 2024

@acdavit About parsing those 32bpp bitmaps? It's a bit odd, I had a poke in the PIL/Pillow source and it suggests that these headers are supported: https://github.com/python-pillow/Pillow/blob/main/src/PIL/BmpImagePlugin.py#L102

Not really sure why the alpha channel is lost though.

@acdavit
Copy link

acdavit commented Nov 18, 2024

@rozniak

Exactly. Would you be okay if I posted the code on stack overflow or Reddit? Maybe someone could shed some light on this mystery.

@rozniak
Copy link
Owner

rozniak commented Nov 18, 2024

@acdavit Yeah by all means go ahead, do whatever you would like if you think it would be beneficial. 👍

@acdavit
Copy link

acdavit commented Nov 18, 2024

@rozniak

Thanks for the response.

I did submit a question to stack overflow, but I also noticed something bizarre while toying around with the resources.

Resource Hacker on Windows does seem to show thumbnails of the alpha channel correctly, but the extracted bitmap lacks it, just like how it does on our Python script.

Screen-Recording.1.webm

Could this, yet again, be the fault of Resource Hacker incorrectly parsing 32bpp bitmaps, or could there be something fishy about how transparency is handled in msstyles?

I'm curious to hear your thoughts on this matter.

@rozniak
Copy link
Owner

rozniak commented Nov 18, 2024

@acdavit Yeah that's why I don't use Resource Hacker for the theme work. 😛

@acdavit
Copy link

acdavit commented Nov 21, 2024

@rozniak

In the fashion of Stack Overflow, my post was removed for being "a duplicate" and referred me to this post.

I did try incorporating this code into yours, but no matter what I tried, it always errors out with "Syntax Error: Not a BMP file".

@BenBE
Copy link

BenBE commented Nov 21, 2024

Have you tried reading the resource section from the binary in question directly? From there parsing out the actual Bitmap resource is kinda straight forward.

@rozniak
Copy link
Owner

rozniak commented Nov 21, 2024

I have dumped out the resources raw before and was a bit bamboozled by the fact that they don't appear to have BMP header (have a look in a hex editor, the signature for a bitmap file isn't there).

Out of curiousity I had a play with Pillow a bit more, noted that it actually is reading using the DIB format, and not BMP.

I'm going to see if it's viable to prepend a bitmap header onto the data, and then see if Pillow is happy to read it as a 32bpp bitmap.

@rozniak
Copy link
Owner

rozniak commented Nov 21, 2024

I'm fairly certain this is a bug with Pillow tbh. Basically the resources here are DIBs with the 40 byte header (BITMAPINFOHEADER), and BI_RGB as the compression (aka uncompressed). I did alter the script to reconstruct the missing BMP file header, just in case it wasn't being read properly by Pillow - I still get the same results though of no alpha channel.

EDIT: Probably suggest fixing this upstream... have a look at this check here which is interesting - could perhaps be a bodge that needs to be amended for this to work? https://github.com/python-pillow/Pillow/blob/main/src/PIL/BmpImagePlugin.py#L245

@babaisgit
Copy link

what modifications would i have to make to implement this? i'd like to use this full time with the zune theme, i figured i'd just do it myself.

@rozniak
Copy link
Owner

rozniak commented Dec 5, 2024

@babaisgit For now you can ignore most of the above conversation, because it relates to trying to automate MSSTYLES --> XFWM4/GTK3 themes.

For doing it manually, you probably want to copy the Silver theme over and start by modifying that. aka copy /themes/luna/metallic into /themes/zune (but do not overwrite the xfwm4 directory, because that's already done).

If you have a look at this commit: 2d1e068

You will see I made Silver by copying and modifying the Blue theme. The metrics are 99% the same (margins, padding, etc.) in all themes, so the majority of the work is essentially just replacing the graphics in the Resources dir.

If you want to talk more about it, ask questions etc. then probably best to continue in #9 😉

@rozniak
Copy link
Owner

rozniak commented Dec 12, 2024

@acdavit @BenBE Good news - I have just had a little poke with the PIL source I linked and yeah, removing that header == 22 check completely fixes the issue. I'm not sure there's a good reason for it, I think it's probably the usual thing where people are only ever interested in ripping icons and cursors and nothing else. I will try and PR a fix upstream.

EDIT:
Slight complication is that there is a 32bpp BMP in the PIL test suite that I'm guessing must be valid, has all 0s for the Alpha channel and is also a 40byte DIB (BITMAPINFOHEADER). MS' documentation does say that the byte isn't used so this would make sense to be valid.

The only difference I can find is that in these bitmaps from Windows, biSizeImage is 0, whereas the image in the test suite does have this set. Of course the documentation says nothing about this, and it seems really weird for this to affect the interpretation of the image but there's nothing else to go off of.

@rozniak
Copy link
Owner

rozniak commented Dec 13, 2024

Solution I may propose to PIL is adding a couple extra 'formats', DIBA and BMPA that pretty much just 'hint' that the alpha channel should be considered. Dunno if upstream will accept it but I'll write up a PR anyway and give it a go.

@rozniak
Copy link
Owner

rozniak commented Dec 13, 2024

Okay so I raised this issue upstream with Pillow here: python-pillow/Pillow#8594

Not sure that my workaround with the extra formats will be worth a merge there, it's up to them. The good news is though is that the developer that responded to my issue was extremely helpful and provided a Python snippet that would read in the alpha channel, working with current Pillow.

I have scrapped my old weird hacky bodgefest and merged this snippet into the ft-uxtheme branch. If you run themgood.py against a .msstyles file now it should dump both the raw DIB and a corresponding RGBA PNG. We are in business. 🥂

@rozniak
Copy link
Owner

rozniak commented Dec 14, 2024

I think for the tool it needs to be a kind of two phase process:

  • First phase to extract out the data from msstyles, DIB->PNG, gather up all the metrics
  • Second phase to generate the themes for each part of the DE -- XFWM, GTK (2, 3, ...4?), Qt(?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants