'inspired with SMCNeill Christmas theme program (this is not Christmas theme program)
'my goal was to enable the storage of two-color bitmaps. This only succeeded after two days,
'because my sources contained a serious error, after comparing with other sources, I found it.
'For this to work, the X-axis (width) image resolution must always be divisible by 32.
'
image$ = "The Season to Color.JPG" ' image name for convert to 2 color bmp file
Type BW
' File Header + Info Header + 2 * _UNSIGNED LONG mask record all in one 'Header
FileSize
As Long ' Size of file DataOffset
As Long ' 62 always in this bitmap type 'infoHeader -----------------------------
SizeOfInfoHeader
As Long ' always 40 Compression
As Long ' 0 = none ImageSize
As Long ' 0, this is size for COMPRESSED IMAGE, 0 for uncompressed XPixels
As Long ' pixels/meter X [0] YPixels
As Long ' pixels/meter Y [0] ColorsUsed
As Long ' 0 = used all colors in mask ImportantColors
As Long ' 0 = all 'color table 2 * _unsigned long record ---> 2 colors image
Do Until Wo
Mod 32 = 0 ' resize image so, that width is dividible by 32 [is condition for this image format] Wo = Wo + 1
W = Wo
clr~& = &HFFFFFFFF '_BackgroundColor(imageO) for christmas theme - all images using white background, for own use set it as you need
Size
= _Ceil(W
* H
/ 8) + 62 ' calculate file size (62 bytes is header + infoheader + 2 colors mask)
BMP1.signature = "BM"
BMP1.FileSize = Size
'BMP1.Unused = 0
BMP1.DataOffset = 62
BMP1.SizeOfInfoHeader = 40
BMP1.Height = H
BMP1.Planes = 0
BMP1.BitsPerPixel = 1
BMP1.Compression = 0
BMP1.ImageSize = Size - 62
BMP1.XPixels = 0
BMP1.YPixels = 0
BMP1.ColorsUsed = 0
BMP1.ImportantColors = 0
BMP1.ColorA = &HFF000000
BMP1.ColorB = &HFFFFFFFF
i = 0
S$ = ""
Dim outpt
(Size
- 63 + corr
) As _Unsigned _Byte ' array for binaries [0 or 1] if image use color mask 0 or color mask 1 outpt(fill) = 0 ' first set all binaries as zero
_Source image
' This image format write image informations to file from bottom to top If r
> 200 Or g
> 200 Or b
> 200 Then S$
= S$
+ "1" Else S$
= S$
+ "0" ' Steve's whiting routine.... If Len(S$
) = 8 Then ' You have 8 points writed as 0/1? Create byte from this 8 bites! outpt(i) = BINtoDEC(S$) ' Write this byte to array outpt
S$ = ""
i = i + 1
outpt(i) = BINtoDEC(S$) ' if here are some binaries, create byte from it and write it to array outpt
S$ = ""
sBINtoDEC = sBINtoDEC + (c * 2 ^ Sj)
BINtoDEC = sBINtoDEC
sBINtoDEC = 0