News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GetPixel/SetPixel

Started by chemicalNova, July 11, 2005, 04:44:15 AM

Previous topic - Next topic

chemicalNova

Howdy all,

I was wondering if there would be a way to create my own GetPixel or SetPixel function. The reason being, I've read the GetPixel and SetPixel API's go through a few proccesses before actual doing anything, making them pretty slow when you need them to be executed in succession. Is there a way to create a function like these, by accessing the DC in memory? I just want to know if theres a faster way to do this..

Ta in advance :D

chem

donkey

Yes, there are several examples here and at Win32ASM, you can download my graphics library from my website for a few GDI replacements for 32 bit DIB bitmaps.

GetDIBPixel FRAME x,y,pDIBits,width,height

mov eax,[width]
mov ecx,[height]

sub ecx,[y]
dec ecx
mul ecx
shl eax,2 ; adjust for DWORD size
push eax ; push the result onto the stack

mov eax,[x]
shl eax,2 ; adjust for DWORD size
pop ecx ; pop the scan line offset off the stack
add eax,ecx

add eax,[pDIBits] ; add the offset to the DIB bit
mov eax,[eax]

RET
ENDF

SetDIBPixel FRAME x,y,pDIBits,width,height,color

mov eax,[width]
mov ecx,[height]

cmp [x],eax
jae >.EXIT

cmp [y],ecx
jae >.EXIT

sub ecx,[y]
dec ecx
mul ecx
shl eax,2 ; adjust for DWORD size
mov edx,eax

mov eax,[x]
shl eax,2 ; adjust for DWORD size
add eax,edx

add eax,[pDIBits] ; add the offset to the DIB bit
mov ecx,[color]
mov D[eax],ecx

.EXIT
RET
ENDF
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

chemicalNova

Wow, thanks for the quick reply donkey. I'll look into it :)

Thanks again,

chem