Archive: CreateBitmap Function


CreateBitmap Function
I made a function called "CreateBitmap". It creates a bitmap depending on the information the user gives. Now it has only 4 parameters, and it requires "${StrTok}" from StrFunc.nsh header file.

How to use it:

Push bitmapfile.bmp # Bitmap file (don't need to be an existant one)
Push width # Width
Push height # Height
Push RRGGBB|[RRGGBB|...] # Colors separated by vertical bars "|" with the format RRGGBB each.

This file below is an small example, but you can customize it as you want. The example will create a bitmap on the same directory where the program is called "CreateBitmapExample.bmp", open it and you'll see a very small example of what is the result. Comments are acceptable.


New version, it now supports 1 bit bitmaps.

Inside the file has an example of 1 bit bitmap with changed palette colors. And the file has the old example for 24 bits bitmaps, just check it out. Instructions can be found inside also.


New version, now it supports 4 and 8 bits bitmaps.

Push BitmapFile.bmp # Bitmap file to write
Push (1|4|8|24) # Bits per pixel
Push ([RRGGBB|...]|default) # Palette colors or "default" for default ones
Push width # Bitmap width
Push height # Bitmap height
Push [RRGGBB|...] # Colors or Palette Index Color Numbers
Call CreateBitmap

More instructions are inside the example section.


Fixed bitmap creation using 4 and 8 bits bitmaps. Same way to call:

Push BitmapFile.bmp # Bitmap file to create
Push (1|4|8|24) # Bits per pixel
Push ([RRGGBB|...]|default) # Palette colors or "default" for default ones
Push width # Bitmap width
Push height # Bitmap height
Push [RRGGBB|...] # Colors or Palette Index Color Numbers
Call CreateBitmap

I'm now focusing on a function to read bitmaps, it will arrive soon...


I forgot to attach the most important thing:


ReadBitmap Function

It reads 1, 4, 8 and 24 bits bitmaps created by any program. The only limitation of the result is the NSIS maximum supportable string size.

It doesn't utilize StrFun.nsh's ${StrTok} but utilizes extra 2 functions (as provided in CreateBitmap function). Not fully tested:

Push BitmapFile.bmp # Bitmap file to read
Call ReadBitmap
Pop var # Output -> palette colors (except for 24 bits)
Pop var # Output -> number of bits (1,4,8,24)
Pop var # Output -> height
Pop var # Output -> width
Pop var # Output -> color indexes (1,4,8 bits) or colors in RRGGBB format (24 bits)

These above are about the same instructions found inside.

TIP: You can use the information of some bitmaps to create others with CreateBitmap.