|
-
May 16th, 1999, 01:43 PM
#1
bitmap pixel manipulation
Imagine a 24 bit bitmap (true color). And suppose you want to make a specific area of the bitmap darker, e.g. a pixel with RGB value (x,y,z) should become (x/2, y/2, z/2). By dividing each pixel by a certain amount, the effect of darkening is achieved.
Iterating through the entire bitmap by manipulating each pixel seperately is one possibility (a relatively slow one). On the other hand a tried a lot of BitBlt's, but unfortunately with no success....
Is there anyone who know an efficient algorithm??
Thanks!!
-
May 16th, 1999, 08:20 PM
#2
Re: bitmap pixel manipulation
Using Shift operators makes the process faster..
instaed of / use >>
eg half=whole>>1;
Hope this helps
-
May 18th, 1999, 04:09 AM
#3
Re: bitmap pixel manipulation
From my point of view it should not be so slow to modify the bitmap But you have two more choices:
- use the windows palette, if you only want to modify the display, not the bitmap by itself
- use MMX assembler code if you want to have the ulitimate speed.
Ralff
-
May 18th, 1999, 02:12 PM
#4
Re: bitmap pixel manipulation
The reason it is slow is because you are using division. Create a table and for every possible value of a pixel(1 through 256) divide the number and fill the table. (that is 256 divisions)
The table should look something like (if you are dividing by 2 lets say)
1 0
2 1
3 1
4 2
...
256 128
table[r] = r/2;
Now transverse through your image if r is the red value new red value rr would be
rr = table[r]; just a look up.
this should speed up the operation.
UNLESS your image has total of less then 256 pixels.
yalcin
[email protected]
-
May 19th, 1999, 10:32 AM
#5
Re: bitmap pixel manipulation
can you use setcolorajustment ? maybe modify the caBrightness
field? clip the dc and do that?
ah well. it tried.
-
May 19th, 1999, 05:55 PM
#6
Re: bitmap pixel manipulation
I eventually found the solution for my problem: manipulate the data bytes corresponding to the pixels in the device independent bitmap directly. After doing so, the new device independent bitmap can be shown on screen by using SetDIBitsToDevice. That's all! And: extremely fast.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|