|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| Googling sadly didn't get me anywhere, so maybe someone can point me in the right direction!
I figured a quick fun weekend project would be a 2bp converter/parser, however I can't find the specification for 2bp anywhere. I assume the header will be fairly similar to bmp, but before I try to reverse engineer it, maybe someone knows where to find the spec |
|
|
|
Global Moderator H/PC Guru Posts: | 7,188 |
Location: | USA | Status: | |
| I know there are a number of 2bp converters… such as reaconverter.
Also understand that WiCE 1 supported only a 2-bit gray scale palette, so use only a bitmap that is 1 bit per pixel (monochrome .bmp) or 2 bits per pixel (.2bp).
But actual file structure itself is something I've never hexedited. |
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| http://justsolve.archiveteam.org/wiki/Pocket_PC_Bitmap
Found this, there used to be a Microsoft knowledgebase article about converting 2bp to bmp, but it's offline and not archived in the internet archive |
|
|
|
H/PC Philosopher Posts: | 297 |
Location: | Chile | Status: | |
| Well, seems to just be a fairly limited BMP.
Do you have example 2bp files? I can help writing a converter or something.
Edited by ShadowMaster 2020-05-13 4:57 PM
|
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| Tried around a bit, I wonder why regular programs fail at parsing 2bp files, it seems to have a just a regular BITMAPINFOHEADER
I made a quick script to look at the headers of a bmp file and a 2bp file, where the 2bp file contains the same picture (with less colors obiously )
Here's the output for BMP
{
biSize: 40,
biWidth: 64,
biHeight: 16,
biPlanes: 1,
biBitCount: 4,
biCompression: 0,
biSizeImage: 512,
biXPelsPerMeter: 0,
biYPelsPerMeter: 0,
biClrUsed: 0,
biClrImportant: 0
}
And 2bp
{
biSize: 40,
biWidth: 64,
biHeight: 16,
biPlanes: 1,
biBitCount: 2,
biCompression: 0,
biSizeImage: 256,
biXPelsPerMeter: 0,
biYPelsPerMeter: 0,
biClrUsed: 0,
biClrImportant: 0
} |
|
|
|
H/PC Philosopher Posts: | 297 |
Location: | Chile | Status: | |
| Quote Karpour - 2020-05-13 11:59 AM
Tried around a bit, I wonder why regular programs fail at parsing 2bp files, it seems to have a just a regular BITMAPINFOHEADER
I made a quick script to look at the headers of a bmp file and a 2bp file, where the 2bp file contains the same picture (with less colors obiously)
I think data would be a little bit trickier to parse, considering it's 2bpp, but shouldn't be hard.
|
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| It wasn't
(2bp.PNG) Attachments ---------------- 2bp.PNG (41KB - 0 downloads) |
|
|
|
H/PC Philosopher Posts: | 297 |
Location: | Chile | Status: | |
| Quote Karpour - 2020-05-13 12:46 PM
It wasn't
Haha well, there you go. I was kinda looking forward to hacking a converter during my lunch break, but you beat me to it.
A standalone converter would be a great addition to the dev resources you are putting together, so maybe porting what you are doing to python or C would be a good idea. |
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| Yeah right now I did it in Typescript, because that's what I use all day at my job. Could make a converter that completely runs in-browser though and host it on HPCFactor maybe
It's just a few lines of code, really simple to port to any language really!
Anyway, I'll clean up the sources and put them on GitHub soon! |
|
|
|
H/PC Philosopher Posts: | 297 |
Location: | Chile | Status: | |
| Quote Karpour - 2020-05-13 1:12 PM
Yeah right now I did it in Typescript, because that's what I use all day at my job. Could make a converter that completely runs in-browser though and host it on HPCFactor maybe
It's just a few lines of code, really simple to port to any language really!
Anyway, I'll clean up the sources and put them on GitHub soon!
I like online tools, but they require to be hosted forever, which is super not great in the long run. Also, my enjoyment of online tools greatly decreases when I experience connectivity issues, or if I'm on vacation and don't have access to a proper internet service or want to remain "offline" for a while to avoid distractions. |
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| Oh yeah I fully agree, my goal is to have a cli tool of course, I just meant that since it's js, you can just embed the same code in a website |
|
|
|
Administrator H/PC Oracle Posts: | 17,976 |
Location: | United Kingdom | Status: | |
| It's easy to reverse engineer in a hex editor, I did once. Had VBScript print a 2bp in the file system.
If you want to do a web one, happy to host it in the toolkit https://www.hpcfactor.com/support/toolkit/ |
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| I just realized I was displaying the image upside-down.. not sure if it's the case with regular bitmaps, but in the file it starts with the line of pixels at the bottom and ends with the line of pixels at the top
I also added that you can pipe images into the app, so if i also implement writing to stdout it can be used with imagemagick for example (Capture.PNG) Attachments ---------------- Capture.PNG (50KB - 0 downloads) |
|
|
|
| Quote Karpour - 2020-05-13 1:45 PM
I just realized I was displaying the image upside-down.. not sure if it's the case with regular bitmaps, but in the file it starts with the line of pixels at the bottom and ends with the line of pixels at the top
Nice work!
A line in a bitmap is called a scan row.
They either start at the bottom or the top based on whether biHeight is positive or negative. Your app will want to do the same or risk inadvertently inverting some images. |
|
|
|
Subscribers H/PC Philosopher Posts: | 439 |
Location: | Austria | Status: | |
| Quote smb_gaiden - 2020-05-13 4:55 PM
They either start at the bottom or the top based on whether biHeight is positive or negative. Your app will want to do the same or risk inadvertently inverting some images.
That's good to know, thanks! So in the current image biHeight is positive, and the scan rows are bottom to top, is that how it's supposed to be? |
|
|