flat assembler
Message board for the users of flat assembler.

Index > Windows > Set/Get Pixel Replacement

Author
Thread Post new topic Reply to topic
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
I need a fast SetPixel and GetPixel API replacement for an app I'm writing, the nearest example I found was over at activevb.de, where it is integrated with VB6 but my german is hopeless and I don't understand the code 'cos it's not FASM. Embarassed

I know that I can use string commands to get and set the pixels but I need the address of the pixels Confused There should be a screen buffer in memory but how do I find it?

If anyone knows how to do this or a better way to do this, it would be very much appreciated.

thanks in advance!
Post 01 Aug 2005, 01:09
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
what? where? how?
Post 01 Aug 2005, 03:33
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
When you ask something, post more information about the context of your problem so people can assist you better. FRUSTRATION LOOMS UPON YOU AND YOUR FRIENDS.

For bitmaps, you can try using GetObject() API to retrieve a pointer to the bitmap bits.

If you create bitmaps yourself, use CreateDIBSection() API so you automatically get the pointer to the bitmap data.

Once you have a pointer to the bitmap data, you can locate the pixel by using this formula:

Code:
ptr = (y * scanline) + (x * bpp / 8)
    


where:
ptr is the offset into the bitmap data (and ultimately the pointer to the pixel you are looking for)
scanline is the width of a single row of pixels in the bitmap, in bytes (usually it is equal to width*bpp/8, and width is aligned on a 32-bit boundary)
bpp is the bitmap depth of your bitmap (24-bits, 32-bits, etc)
Post 01 Aug 2005, 03:37
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
In complexity, this is equal to regular GDI GetPixel/SetPixel. However, I can imagine that those two functions have a lot of overhead to deal with (colour-space conversion, etc). The optimization comes when you have to make concurrent calls to GetPixel/SetPixel. For example, if are reading every pixel in a bitmap after each other, it is not necessary to call GetPixel everytime. Instead you should start with the pointer to the bitmap, read the pixel, then advance the pointer by the size of the pixel. Do not forget to take care of the padding at the end of rows.
Post 01 Aug 2005, 03:43
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
First, sorry if I annoyed you in any way.

Context: I have 4 bitmaps created with CreateCompatibleBitmap API: one has the loaded bitmap for the window skin, the second has a desktop blit from BitBlt, the third has a loaded alpha blend map and the fourth is the destination bitmap.

The skin and desktop capture are combined using an alpha blend routine, where the alpha blend varies with the alpha blend map. Then the destination bitmap is blitted to the window using BitBlt.

BitBlt, SetPixel and GetPixel are slow, so by replacing these API, the result should be more pleasing.

Here's what it looks like: [LINK REMOVED]
Post 01 Aug 2005, 10:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.