ASM: Copying array data

Started by
0 comments, last by CGameProgrammer 24 years, 6 months ago
I'm trying to write a routine to load a bitmap from a file, in Assembly. (I'm insane.) An error occurs when I try copying the BGR information from the bitmap to a temporary RGB array.

Here's the situation: Both have been successfully allocated, with EDX pointing to the source of BGR (blue,green,red) byte triplets, and EBX pointing to an array that I need to fill with R,G,B byte triplets. ECX holds the size (width*height) of the bitmap.

Code:

BeginLoop:.If g_wBitsPerPixel == 24	Add EDX, 2 ; Position src ptr so we're at the red value.Mov AL, Byte Ptr [EDX]Mov Byte Ptr [EBX], ALInc EBXDec EDX ; Position src ptr so we're at the green value.Mov AL, Byte Ptr [EDX]Mov Byte Ptr [EBX], ALInc EBXDec EDX ; Position src ptr so we're at the blue value.Mov AL, Byte Ptr [EDX]Mov Byte Ptr [EBX], ALInc EBXAdd EDX, 3 ; Position src ptr for next loop..EndIfDec ECXCmp ECX, 0JNE BeginLoop ; If ECX != 0 goto BeginLoop

Somewhere in there, an error is occuring. Any ideas?

------------------
~CGameProgrammer( );

[This message has been edited by CGameProgrammer (edited October 05, 1999).]

~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
Advertisement
Are you taking into account that the bitmap width must be a multple of 4?

Jim

This topic is closed to new replies.

Advertisement