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

2bp specifications

Moderators: C:Amie

Jump to page : 1 2
Now viewing page 1 [15 messages per page]

Karpour Page Icon Posted 2020-05-13 3:31 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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
 Top of the page
Rich Hawley Page Icon Posted 2020-05-13 3:59 PM
#
Avatar image of Rich Hawley
Global Moderator
H/PC Guru

Posts:
7,000
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.
 Top of the page
Karpour Page Icon Posted 2020-05-13 4:02 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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
 Top of the page
ShadowMaster Page Icon Posted 2020-05-13 4:56 PM
#
Avatar image of ShadowMaster
Subscribers
H/PC Philosopher

Posts:
279
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
 Top of the page
Karpour Page Icon Posted 2020-05-13 4:59 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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 
}
 Top of the page
ShadowMaster Page Icon Posted 2020-05-13 5:05 PM
#
Avatar image of ShadowMaster
Subscribers
H/PC Philosopher

Posts:
279
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.
 Top of the page
Karpour Page Icon Posted 2020-05-13 5:46 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
Location:
Austria
Status:
It wasn't





(2bp.PNG)



Attachments
----------------
Attachments 2bp.PNG (41KB - 0 downloads)
 Top of the page
ShadowMaster Page Icon Posted 2020-05-13 5:57 PM
#
Avatar image of ShadowMaster
Subscribers
H/PC Philosopher

Posts:
279
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.
 Top of the page
Karpour Page Icon Posted 2020-05-13 6:12 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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!
 Top of the page
ShadowMaster Page Icon Posted 2020-05-13 7:06 PM
#
Avatar image of ShadowMaster
Subscribers
H/PC Philosopher

Posts:
279
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.
 Top of the page
Karpour Page Icon Posted 2020-05-13 7:26 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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
 Top of the page
C:Amie Page Icon Posted 2020-05-13 8:07 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
15,423
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/
 Top of the page
Karpour Page Icon Posted 2020-05-13 9:45 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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
----------------
Attachments Capture.PNG (50KB - 0 downloads)
 Top of the page
smb_gaiden Page Icon Posted 2020-05-13 9:55 PM
#
Avatar image of smb_gaiden
Factorite (Elite)

Posts:
210
Status:
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.
 Top of the page
Karpour Page Icon Posted 2020-05-13 10:45 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
256
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?
 Top of the page
hpc:factor« View previous thread · Developers Arena · View next thread »

Jump to page : 1 2
Now viewing page 1 [15 messages per page]

Jump to forum:
Seconds to generate: 0.078 - Cached queries : 51 - Executed queries : 30
Server Time now is: Thursday, 26 November 2020 - 15:40