ok i dont know if this is in the right forum, but im looking for a tutorial on how to work with hds, i want to create a function just like bitblt (well, actually its a 50% transparancy blit but i already got that part done :))

thnx, Scorpie
Posted on 2004-07-18 16:42:30 by diguin
a hdc doesn't give you direct access to anything - the best you can do actually _is_ BitBlt :). Another good solution would be DirectX, as you can get hardware accelerated alpha blits that way (and will have a VERY hard time beating that in software).

If you want to do it manually, you'd want to get at some bitmap structures...
Posted on 2004-07-18 17:04:18 by f0dder
i want to "recreate" bitblt(meaning, i want to build it myself) i want to understand how it works, do you know a tut about that?
Posted on 2004-07-18 17:09:17 by diguin
To recreate bitblt completely, you would need access to several internal windows structures - this is not going to happen. Furthermoe, you wouldn't be able to take advantage of hardware acceleration.

If you want a _similar_ function that does more or less the same, but works directly on bitmap images (rather than from HDCs), that's a different story :)
Posted on 2004-07-18 17:28:56 by f0dder
hmm, 2 bad i wanted to create a new kinda blt, but ill keep on searching then :)
Posted on 2004-07-18 18:04:04 by diguin
well, there's a LOT of stuff to do... first there's the hardware acceleration. Next, consider things like color conversion (on the fly), stretching/shrinking, clipping, ...
Posted on 2004-07-18 18:14:46 by f0dder
i was thinking, what ure saying may be right but then there should be another way to achieve my goal, photoshop can do what i want to do, it can set 2 pictures above each other and make then half transparent, i managed to do this but my code is still slow so i thought working with hds was the way to make it faster is this correct or not? and how can i make this stuff that photoshop can? can you give me a little push in the right direction?
Posted on 2004-07-19 08:19:10 by diguin
I would be very surprised if photoshop doesn't work directly on the pixel data without any GDI calls. After all, they have to be able to produce the exact same results on different machines, no matter what kind of hardware acceleration is available.

So, rather than focusing on HDCs, you should look at working directly with bitmap data. If you create a windows bitmap with the use of CreateDIBSection, you can have direct access to the pixel data.
Posted on 2004-07-19 09:10:35 by f0dder
So would I, because PS can perform alpha blending using a gradient (the alpha value can be changed per pixel).
Posted on 2004-07-21 21:48:46 by Homer
you can also create an offscreen canvas alike thing where you SetPixel(..) and then blit on the main window.
Posted on 2004-07-22 08:20:04 by Mbee
setpixel sucks as far as i can see from other topics.

thnx for your sugestions, i tryed a bit around with createDIBsection and i think it is perfect for my purpose.
i also have another question about 32 bit-colors, you have an R, G, B and a 'reserved' value, where is this reserved value used for?
Posted on 2004-07-22 10:27:33 by diguin
sometimes it is used as alpha channel, but in your case it is used as padding, since our x86's rather work with DWORDS than 3byte primitives (didn't they have a name? i can't remember it). same applies for 24bit or 32bit color, it has the same detail, one byte per r/g/b.
Posted on 2004-07-22 11:46:27 by Mbee
setpixel sucks as far as i can see from other topics.

Well, now, I s'pose that fully depends on your needs, but SetPixel certainly does
not just inherently suck (for lighting up pixels). It's all I used in this:


(which is based on an algorithm described in this

Well... I say it's "all I used", but I mean it's all I used for the drawing routine (it uses
good ol' BitBlt for restoring...)

Posted on 2004-07-23 03:17:29 by jayte
ok, i didnt mean suck but i meant as far as i can see from other topics, SetPixel is slower than using somehting like CreateDIBSection.

btw, what does that prog do? just zoom in on some picture?
Posted on 2004-07-23 10:38:21 by diguin
btw, what does that prog do? just zoom in on some picture?

Mandelbrot fractal generator. Was a DOS program of mine, *way* back,
that I one day began to re-write for Windows.

I was just surprised, myself, when I first saw the speed at which those
"disks"--that the thing draws with--appear. Wasn't expecting that, at *all*,
from SetPixel. Oh, and if you've heard about how reading your system's
graphics memory is so much slower than writing... You oughta see how
much just one GetPixel slows the whole thing down (that is, scanning/drawing
one complete image takes noticeably longer).


Posted on 2004-07-24 00:12:52 by jayte