PDA

Click to See Complete Forum and Search --> : DD Image darkening


git
May 14th, 2001, 07:18 AM
Hi,

Is it possible to blit an image to screen with DD/BltFast (fullscreen), and also darken it to a certain amount? Is there an easy way to do this?

-Git

Sastraxi
May 14th, 2001, 07:25 AM
Well you could make a black surface (bltcolorfill it) and then alphablend them together w/microsoft's alphablend function.

Jotaf98
May 14th, 2001, 09:51 AM
Nah, I think that function only works in Win98 (not sure). You should use something more reliable, like a custom DLL :p

Look for vbDABL, it's the best one in my opinion. You can find it in any search engine I think, if not, reply here and I'll e-mail it to you.

PsychoMark
May 14th, 2001, 01:31 PM
:mad: That DLL won't work without MMX, and my own pc doesn't have MMC :mad:


If you really want control and speed, plus some other nice things like rotation, you could also use Direct3D:

Direct3D -> 2D, Rotation (http://www.planetsourcecode.com/xq/ASP/txtCodeId.21337/lngWId.1/qx/vb/scripts/ShowCode.htm)
Direct3D -> 2D, Faking Light (the darkening you're looking for) (http://www.planetsourcecode.com/xq/ASP/txtCodeId.21453/lngWId.1/qx/vb/scripts/ShowCode.htm)
Direct3D -> 2D, Alpha Blending (http://www.planetsourcecode.com/xq/ASP/txtCodeId.21554/lngWId.1/qx/vb/scripts/ShowCode.htm)


Those are samples I've uploaded to PSC when I started using Direct3D for 2D graphics...

Jotaf98
May 14th, 2001, 05:39 PM
Yeah, that's cool. The only reason why it's not THAT widely used, is that it only works decently with a hardware accelerator... of course you could add the option to turn off those effects, but maybe having a "backup plan" would be better :)

I've heard ASM is really fast. Maybe faster than C++. But which one do you think would be easier to make a special effects DLL? :confused:

PsychoMark
May 15th, 2001, 02:08 AM
I don't know ASM, but I started learning C++ and Delphi recently. Delphi is easier, but I think C++ is a little faster (haven't really tested the Delphi DLL, but the C++ DLL was 900% faster than VB!!!!). AFAIK, ASM is a little faster than C++, but I never even tried to understand it...

Btw, the test I performed was between a C++ DLL, and a VB ActiveX DLL, both doing array manipulation to change pictures (without lookup tables)... there's an example at http://www.vbexplorer.com/directx4vb/ (Code -> General VB Gaming -> C++ DLL), which I used as a base for my code, not too difficult really...

Jotaf98
May 16th, 2001, 03:14 AM
Hey PsychoMark, thanks for the link! I've been looking for that for AGES!!! And it's easier than I thought ;)

Also, why did that DLL work only with MMX, and is it THAT fast?

PsychoMark
May 16th, 2001, 03:50 AM
It uses MMX because of some 64-bit buffers or something. I don't know much about it, but it's explained at the DirectX4VB site...

Don't know how fast it is; my P133 doesn't have MMX, so even though I have a P550 which does support it, I forgot about it ASAP (didn't want to force the user to have MMX)...

git
May 16th, 2001, 03:53 AM
Hmm...is there any way to do it with Direct X/Draw 7? I'd prefer not to use DX8 or D3D (my entire program is written in DD7), but I guess I might not have a choice.

-Git

PsychoMark
May 16th, 2001, 04:31 AM
For your problem, there are generally 3 ways:

- create some slow VB code
- create a C++ DLL which handles it
- use Direct3D

Jotaf98
May 18th, 2001, 10:09 AM
Don't worry, I'm doing it the DLL way right now, all you gotta do is wait :)

I'll use the same code to generate the lookup tables as in another special effects module I made, for BitBlt games. To have a look at it, look for "Special Effects for BitBlt", somewhere in this forum. But this time it's gonna be for DDraw ;)

PsychoMark
May 18th, 2001, 10:15 AM
You can amazing things with the DirectDraw GetLockedArray function and a C++ DLL, that's for sure.... I almost can't wait to see your DLL Jotaf98 :)

Also, if you make the DLL accept an array, you can use it for both the DD GetLockedArray call and you can apply it to normal PictureBoxes (I've got a sample program here which get's an array from a picture for fast manipulation, somewhat like the GetLockedArray thing, which is pretty fast, a lot faster then Get/SetPixel anyways). Now wouldn't that be nice :D

Jotaf98
May 20th, 2001, 09:38 AM
The DLL is coming a long good, I've done it in VB and it works very well, so all I need to do now is translate it into C++.

The DLL will manipulate ARRAYS, not surfaces! You can use it with anything you want, as long as it's 24-bits, NO MATTER IF IT'S RGB OR BGR. Also, the lookup tables will be built-in, so all you have to do is write a simple blting function that handles cut edges (I'll provide one, so don't worry) :)