Message board for the users of flat assembler.
> Tutorials and Examples > How to display raw image in Win32?
Hi, I am nearly one month on FASM message board.
I have both an example to share and a question to ask fellow coders:
Example to share:
1) ENTRY.com is a DOS program that display the attached raw image
2) HUGI.raw is a raw image (always 64768 bytes) as defined below:
The ENTRY.com has HUGI.RAW embedded and compressed, that is why the program is smaller than the size of RAW image itself.
ENTRY.com was my old code for an Asm size-optimizing contest many years ago:
; This is my own compression technique. ; Two different compression techniques employed here. ; The palette is compact through 8-to-6 bit transformation. ; The image data is compact through frequency table. .MODEL Tiny .286 .CODE .STARTUP push cs pop ds push 0a000h pop es mov al, 13h int 10h mov dx, 03c8h xor ax, ax out dx, al inc dx mov cx, 192 mov si, OFFSET Palette NextPalette: lodsw mov bx, ax lodsb mov ah, al mov al, bl shr al, 2 out dx, al shl bl, 6 shr bl, 2 mov al, bh shr al, 4 or al, bl out dx, al shl bh, 4 shr bh, 2 mov al, ah shr al, 6 or al, bh out dx, al mov al, ah and al, 03fh out dx, al loop NextPalette xor di, di add si, 90 NextImage: lodsb push si mov cx, 45 mov si, OFFSET FrequencyTable NextTable: mov bx, [si] cmp bh, al jz Expand inc si inc si loop NextTable stosb pop si cmp di, 60480 jae Exit jmp NextImage Expand: pop si lodsb mov cl, al mov al, bl rep stosb cmp di, 60480 jae Exit jmp NextImage Exit: xor ax, ax int 16h mov ax, 03h int 10h mov ah, 4ch int 21h Palette db 576 DUP(?) FrequencyTable dw 45 DUP(?) END
My question! How do I display the abovesaid raw image in Windows ? Do I need to use Win32 API (since I cannot use BIOS interrupt anymore)?
Can someone please share an Asm example for Win32 equivalent? Thanks!
|20 Feb 2021, 13:05||
This function might be a good start. The BMP format is just a bit more complicated than your RAW one, but this function just wants you to supply relevant parts of data. I guess, you’ll only need to scale the R, G and B values in the palette since they’re now 0…255.
Painting the bitmap may be performed in many different ways. In fact, if you only want to paint the bitmap and have no intent to use it anywhere else, plain StretchDIBits might be just enough and maybe even too cool.
|21 Feb 2021, 09:00||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.