PDA

View Full Version : Another alphablending question



Asmod
07-02-2003, 07:56 PM
I'm using DelphiX with Delphi 6 and was playing with the drawalpha functions. I have a few questions

Could anyone tell me what the patternindex integer is used for?

DXImageList1.Items[x].drawalpha(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer; Alpha: Integer);

all I have found out is if its set to anything other than 0 it doesn't draw your image and the other is, if I draw an object using any of the alpha functions the object appears green. I guess I'm doing something wrong, anyone have any ideas on that?

Thanks

Asmod.

Useless Hacker
07-02-2003, 08:44 PM
Could anyone tell me what the patternindex integer is used for?

It is used to allow you to combine multiple images the same size, into one single image, which is especially useful for animation and tiling. You can divide the image up using the PatterWidth and Pattern Height properties of the TPictureCollectionItem object (also the SkipHeight and SkipWidth properties)

The PatternIndex then specifies which part of the image to draw:


-------------------
|0 |1 |2| 3| 4| 5|
-------------------
|6 |7 |8| 9|10|11|
-------------------
|12|13|14|15|16|17|
-------------------



I have no idea why anything would be going green. The Alpha value should be between 0 and 255.

TheLion
07-02-2003, 08:51 PM
Sure I can... The PatternIndex is usefull when you are using a tiled bitmap, with that I mean, say you have an animation of a walking mario, and say each your total picture is 690x64 and each frame of your animation is 64x64 then you can set the patternwidth of the image to 64 and the patternheight to 64. Each time you draw the image to the screen, a rect is calculated with the size of your frame, so in short it only draws the frame you want, so if I wanted the 4th frame I set PatternIndex to 4, if I want the 10th frame then I set the patternIndex to 10...

I hope I make a bit of sense... It's hard to explain without having examples... Take a look at the pacman image over at this URL
http://delphigamedev.name2host.com/dxtut3b.htm and you'll see what I mean, each pacman frame has the same with and so you could make an animation using the patternindex (the tutorial uses the SpriteEngine to make animations, but if you want you can do it yourself with the patternindex).

Asmod
08-02-2003, 12:02 AM
ah thanks, I've used tiled bitmaps before :) the green alpha blend is the weird one though. Maybe I have some settings wrong but this is what I mean by green !!


The image on the bottom right should be the same as the image on the bottom left (colourwise) the only difference is one was drawn using the drawalpha function

http://netgs.co.uk/asmod/alpha_175.jpg

TheLion
08-02-2003, 09:09 AM
What image type are you using, I'm no expert on alpha drawing, but it might be a color problem or a image type problem... Just a guess though :)

Asmod
08-02-2003, 09:22 AM
its a png, thats a good point though, I'll try a few different types

Ultra
08-02-2003, 01:15 PM
I belive that DelphiX for Delphi6 has a bug when it comes to alpha drawing, and that is why you get green. Sadly, I don't know how to fix this. :(

Asmod
09-02-2003, 04:25 PM
I belive that DelphiX for Delphi6 has a bug when it comes to alpha drawing, and that is why you get green. Sadly, I don't know how to fix this. :(

oh :( ok, well thanks for the replies one final question then,

Whats a good replacement for DelphiX that can handle alphablending and stuff? The headers from http://www.crazyentertainment.net/ ? or something else?

User137
25-02-2003, 08:19 AM
There is free Graphics32 out there. It has even alpha-channeled bitmaps (transparency varies at each pixel) and it doesn't need DirectX.
But DelphiX is The primary graphics component that you should not forget. Even if you don't use DelphiX for graphics, it still has easy Internet/Networking, sound and input capabilities.

Harry Hunt
10-03-2003, 08:55 PM
if you don't mind me advertizing my own component set here... :D

http://www.xsdevkit.com

does fast alpha blending and alpha channels using DirectXGraphics. You might want to check it out.
It doesn't have network components yet, but of course you can continue to use the DelphiX ones.

JanBacke
11-03-2003, 02:06 PM
Why does some people still use DelphiX???? :roll:
I can't understand this. DelphiX is such an old and buggy interface.

patroclus02
11-03-2003, 03:04 PM
JanBacke you're right, but it is also the easiest.
I'm now warping to PowerDraw 3 (and also Omega) and this takes a lot of time. what do you use?

JanBacke
11-03-2003, 07:36 PM
I'm using the directx 9 headers from Ampaze http://www.crazyentertainment.net and they're working fine 8) . But what i want to say is that some people are frighten when they want to use "the big interfaces" DirectX, OpenGL and SDL and read about them. People say that you've a lot to do with Com Interfaces, matrices and such complex things. Certainly they are right :lol: But if you work just a little time with it and build your first framework u won't work with any other component. For the first time I've also worked with DelphiX. And I can say there were more disadvantages then advantages.
The performance was not really good, especially the 3D Area :twisted: . Often I could not find any documentation or samples and so on. But today I'am a satisfied DirectX user. :D

sorry for my bad spell