x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Extracting icons from CE1.0 exe files

Karpour Page Icon Posted 2023-05-10 10:29 AM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
440
Location:
Austria
Status:
For my ongoing archiving efforts, I'd like to be able to automatically extract and convert icons from exe files.
7zip can extract the files out of the .rsrc/ICON resource, but what I end up with are several files that the linux file utility identified as DIB (Device Independent Bitmap) files.
ImageMagick has an decoder for DIB, but it doesn't work with these files. What I assume is that these are 2-bit DIB files, just like .2bp files are technically bmp files with a nonstandard 2-bit depth, these are probably just DIB files with a 2-bit depth that no software can really handle.

So the question is, does anyone have an easy way to convert these into other formats? I don't fancy writing yet another decoder
 Top of the page
C:Amie Page Icon Posted 2023-05-10 2:30 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
18,011
Location:
United Kingdom
Status:
Have you tried opening them as .2bp files on the device to see if they are literally .2bp files? Do they even have alpha channel information?
 Top of the page
Karpour Page Icon Posted 2023-05-10 10:18 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
440
Location:
Austria
Status:
No, they're not 2bp files. Considering it's identified as a DIB file, and DIB files, like bmp files, usually have either 1, 4, 8, 24 or 32 bit color, I'm pretty sure this is a 2-bit variant of DIB that no software can handle. I haven't found any tools that can handle these files, so I might have to write one after all.
 Top of the page
C:Amie Page Icon Posted 2023-05-10 11:36 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
18,011
Location:
United Kingdom
Status:
From what I can see, they're

RGB(0,0,0), RGB(132,132,132), RGB(198,198,198), RGB(255,255,255) + 1-BIT ALPHA. So it must have a secondary alpha table mask.
 Top of the page
PhMajerus Page Icon Posted 2024-03-03 2:57 AM
#
Avatar image of PhMajerus
H/PC Newbie

Posts:
9
Location:
Switzerland 
Status:
They are 3bpp Icons, but not just DIBs, Icons resources have the DIB for the image itself, which is a 2bpp DIB on 4-grays WinCE, and a 1bpp mask to set the pixels transparency.
They originally used a .ic2 extension for those icons instead of .ico, although the icon header is standard and any app can simply see the bit-depth set to 2. Could be good to try the alternate extension just in case your software only support 2bpp in .ic2 files.
WinNT GDI does not support 2bpp DIBs, so anything that relies on the Win32 API handling of icon resources will fail.

You need to handle both the image 2bpp DIB and the 1bpp mask DIB to convert them properly. The simplest solution is probably to just convert the 2bpp DIB to 4bpp, and then you can keep the mask as it and further process it like a normal NT icon.

If you want to validate your extracted resources, I have a piece of software that can handle them to display them, but doesn't convert them.


Edited by PhMajerus 2024-03-03 3:00 AM
 Top of the page
CE Geek Page Icon Posted 2024-03-03 11:06 PM
#
Avatar image of CE Geek
Global Moderator
H/PC Oracle

Posts:
12,672
Location:
Southern California
Status:
Nice to hear from you, PHM. As one who developed lots of very useful tools for us CE users, we hope you'll stick around.
 Top of the page
torch Page Icon Posted 2024-03-06 2:34 AM
#
Avatar image of torch
Subscribers
H/PC Guru

Posts:
5,758
Location:
United States 
Status:
PhMajerus - 2024-03-02 7:57 PM


If you want to validate your extracted resources, I have a piece of software that can handle them to display them, but doesn't convert them.

@PhMajerus If it's no trouble - and you're able/willing - is the binary available so we can add that to the SCL? Even if it's not CE Native, we can still add it because of its relevance as a "Host Application"
 Top of the page
PhMajerus Page Icon Posted 2024-03-07 5:38 PM
#
Avatar image of PhMajerus
H/PC Newbie

Posts:
9
Location:
Switzerland 
Status:
It's part of the libraries included with my v2 version of ActiveScript Shell (pka Majerus.net ActiveShell which was also on CE).
Basically since I like pixel-art, ANSI-art, and the terminal, I included a component that can load icons, bitmaps, images, fonts,... and render them as ANSI-art (text with mosaic characters and colors control sequences to display in the terminal).

Since I wrote the code to convert .ico and .bmp to ANSI-art, without relying on any API except file access, I decided to include support for WinCE 2bpp bitmaps and icons as well.

I don't think it should be included in your apps library since it's not WinCE and is getting new versions regularly without clear versioning at this point.
But you can grab it directly from my public OneDrive folder at https://onedrive.phm.lu/
Take "Majerus.net ActiveScript Shell (x64).msi" or "Majerus.net ActiveScript Shell (x86).msi" depending on your OS architecture, and try the following commands in JScript at the prompt:

var ansi = new ActiveXObject("Majerus.ANSI"); echo(ansi.loadIcon("axsh.exe,0", 16, 16, 4));


This shows how to get the first icon from a .exe (index is zero-based), use the 1st 16×16 4bpp image of that icon, and render it in the terminal.
If you specify a .ico or .ic2 you just provide the filename (with the path, doubling backslashes because it's the escape character), for .icl, .exe, .dll, it will use the default (first) icon if only the filename is specified, but you can use the same syntax as used by the shell in the registry to specify the icon, using the comma and an icon index as a positive number, or an icon resource ID as a negative number (as in "axsh.exe,-101" would get icon ID#101).
For WinCE 2bpp icon, you simply specify 16, 16 or 32, 32 for the size you want, and 2 for the bit depth, as in
echo(ansi.loadIcon("C:\\some path\\winceapp.exe,0", 16, 16, 2));

Note it does not perform any conversion, the dimensions and bit depth requested must be in the specified icon resource.

Use the following command for more details:
docs(ainsi, "loadIcon");
 Top of the page
PhMajerus Page Icon Posted 2024-03-07 5:43 PM
#
Avatar image of PhMajerus
H/PC Newbie

Posts:
9
Location:
Switzerland 
Status:
CE Geek - 2024-03-04 12:06 AM


Nice to hear from you, PHM. As one who developed lots of very useful tools for us CE users, we hope you'll stick around.


Thanks, I'll try to help out with information I remember when I can.
 Top of the page
torch Page Icon Posted 2024-03-09 6:17 AM
#
Avatar image of torch
Subscribers
H/PC Guru

Posts:
5,758
Location:
United States 
Status:
PhMajerus - 2024-03-07 10:38 AM


It's part of the libraries included with my v2 version of ActiveScript Shell (pka Majerus.net ActiveShell which was also on CE).
Basically since I like pixel-art, ANSI-art, and the terminal, I included a component that can load icons, bitmaps, images, fonts,... and render them as ANSI-art (text with mosaic characters and colors control sequences to display in the terminal).

Since I wrote the code to convert .ico and .bmp to ANSI-art, without relying on any API except file access, I decided to include support for WinCE 2bpp bitmaps and icons as well.

I don't think it should be included in your apps library since it's not WinCE and is getting new versions regularly without clear versioning at this point.

I appreciate the explanation. In the SCL, there is some precedent in regards to some non-Windows CE programs being present.
For example, we have BMP2BP
Quote
Convert .bmp image files into Windows CE standard .2bp image files for displaying on monochrome Windows CE devices on your host PC
.

I went ahead and added to the SCL with the following note:

https://www.hpcfactor.com/scl/2316/Philippe_Majerus/Majerus.net_ActiveScript_Shell/version_2.0

HPC:Factor Note: This program can be used to display 2bp files, but does not convert them. For more details, please see the following HPC:Factor Forum Thread by the Developer, Philippe Majerus (PhMajerus)
https://www.hpcfactor.com/forums/forums/thread-view.asp?tid=20947

If you disagree about its inclusion in the SCL, please let me know, and I'd be happy to oblige your request 100% - I just think since we have BMP2BP in the SCL, that this would be useful to have as well.

As always, thank you for your help! It's great seeing you as a member here.

Here’s another thread I had found about 2bp too
https://www.hpcfactor.com/forums/forums/thread-view.asp?tid=18819&start=1


Edited by torch 2024-03-09 8:19 AM
 Top of the page
Jump to forum:
Seconds to generate: 0.171 - Cached queries : 66 - Executed queries : 10