Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Siekmanski

Pages: [1]
1
Hi Vil,

No need for bloated 3th party image libraries.
You can use GDIplus for that with a few lines of code.
It can load bmp, gif, jpeg, png, tiff and ico files from disk ( or from memory or from resource section ) and decompress it to memory as uncompressed raw ARGB data.

Here is an example to load a bitmap image from disk in Masm. ( and it's very very small.  ;D)

Code: [Select]
include     \masm32\include\gdiplus.inc
includelib  \masm32\lib\gdiplus.lib

.const

; GDI+ info
ImageLockModeRead               equ 1
PixelFormat32bppARGB            equ 26200Ah

GdiplusStartupInput struct
    GdiplusVersion              dd ?
    DebugEventCallback          dd ?
    SuppressBackgroundThread    dd ?
    SuppressExternalCodecs      dd ?
GdiplusStartupInput ends

BitmapData struct                         
    dwWidth                     dd ?   
    dwHeight                    dd ?   
    Stride                      dd ?   
    PixelFormat                 dd ?   
    Scan0                       dd ?   
    Reserved                    dd ?
BitmapData ends

GdiplusInput   GdiplusStartupInput <1,NULL,FALSE,FALSE>

.data?
; GDI+ data
align 4
pImage              dd ?
ReturnMessage       dd ?
GdiplusToken        dd ?
GDIplusBitmapData   BitmapData <?>
FilenameW           dw MAX_PATH dup (?)
ARGB_raw_buffer     dd 640 * 480 dup (?) ; memory to hold a raw 32bit bitmap of 640*480

.data

NicePicture         db "NicePicture.png",0

.code

align 4
GDIp_LoadBitmap proc uses ebx esi edi ImageName:DWORD,pBitmap:DWORD

    mov      ReturnMessage,FALSE

    invoke  GdiplusStartup,offset GdiplusToken,offset GdiplusInput,NULL
    test    eax,eax
    jnz      Exit_LoadBitmap
   
    invoke  MultiByteToWideChar,CP_ACP,0,ImageName,-1,offset FilenameW,MAX_PATH-1
    invoke  GdipCreateBitmapFromFile,offset FilenameW,addr pImage
    test    eax,eax
    jnz      ShutdownGDIplus

    invoke  GdipBitmapLockBits,pImage,NULL,ImageLockModeRead,PixelFormat32bppARGB,offset GDIplusBitmapData
    test    eax,eax
    jnz      Close_Image

    mov      esi,GDIplusBitmapData.Scan0     ; pointer to the bitmap data
    mov      edi,offset ARGB_raw_buffer      ; pointer to the output bitmap data
   
    mov      ecx,GDIplusBitmapData.dwHeight
Height_lp:
    mov      edx,GDIplusBitmapData.dwWidth
    xor      ebx,ebx
Width_lp:
    mov      eax,dword ptr [esi+ebx]   
    mov      dword ptr [edi],eax
    add         edi,4
    add      ebx,4
    dec      edx
    jnz      Width_lp
    add      esi,GDIplusBitmapData.Stride   
    dec      ecx
    jnz      Height_lp   

    mov      ReturnMessage,TRUE

    invoke  GdipBitmapUnlockBits,pImage,offset GDIplusBitmapData

Close_Image:
    invoke  GdipDisposeImage,pImage
ShutdownGDIplus:
    invoke  GdiplusShutdown,GdiplusToken
Exit_LoadBitmap:
    mov      eax,ReturnMessage
    ret
GDIp_LoadBitmap endp

; load bmp, gif, jpeg, png, tiff and ico files from disk and decompress to memory as uncompressed raw ARGB data.

    invoke      GDIp_LoadBitmap,offset NicePicture,offset ARGB_raw_buffer

2
About the gouraud shade colors in quads on virtual machines, I have no idea.

3
Hi ViL,

A while ago I wrote an example for my little nephew.
He wanted to experiment with OpenGL and Masm.
Wrote some basic routine in one program.
Switching 2D and 3D mode, rotated cube with textures ( transparent color can be set, jpg gif bmp can be loaded from disk and resource section )
Background picture, transparent Bitmap font and a simple line draw function.
Some lables are in Dutch.....

Franck Charlet "Hitchhikr" wrote a lot of very cool OpenGL examples in Masm. http://perso.orange.fr/franck.charlet/Ogl_Asm.zip

4
Hi Knurz,

Code: [Select]
push HWND
push offset MsgText
push NULL
push NULL
call MessageBox

The push order should be reversed.

Code: [Select]
push NULL
push NULL
push offset MsgText
push HWND
call MessageBox



5
Hi ViLXDRYAD,

Did you know there is also a Masm Forum ( it has even a new Game Development section )

http://masm32.com/board/index.php

6
    .686p
    .model  flat,stdcall
    .xmm
    option casemap:none

    include       \masm32\include\windows.inc
    include       \masm32\include\kernel32.inc
    includelib    \masm32\lib\kernel32.lib
    include       \masm32\include\user32.inc
    includelib    \masm32\lib\user32.lib


Assemble and link:

Ml.exe /c /coff yourprog.asm
Link.exe /SUBSYSTEM:WINDOWS yourprog.obj


7
Game Showcase / Re: Andromeda Wing
« on: September 12, 2017 »
Looks awesome, very well done.  :kewl:

8
General chat / Re: The Welcoming Committee
« on: June 06, 2017 »
Hello guys and girls.
This is my first post to introduce myself. I'm an old Dutch guy interested in 2D/3D programming, sound programming and DSP stuff.
Started in 1988 programming on the Amiga500 in asm after I saw all those mind-blowing intros.
Nowadays I just code for fun in assembly on my Windows box, using my favorite assembler Masm.
It's cool to meet people which share my interests, thats why I joined this forum.

Pages: [1]