Hello. How im able to draw pictures with different rgb's?
Hello. How im able to draw pictures with different rgb's?
www.netsoccer.biz
You?¢_Tre question doesn?¢_Tt make much sense, do you mean using palettes or color modulation or something?
I'm assuming that you are meaning draw a greyscale image using an RGB color?
Turn off the grayscale mode of your monitor. This will show color picture instead of black and white. You may need to acquire a different monitor, if your current monitor does not have the mentioned feature.Originally Posted by Jonne
Hi Jonne,Originally Posted by Jonne
You have numerous options available to you. The first and simplest way is to use the pixels property of the TDXDraw surface, like this:-
[pascal]
dxdraw1.surface.pixels[x,y]:=aColor;
[/pascal]
You can also fill an area of the surface, like this:-
[pascal]
var
dst : TRect;
begin
dst.top:=10;
dst.bottom:=30;
dst.left:=10;
dst.right:=30;
dxdraw1.surface.fillRect(dst,aColor);
end;
[/pascal]
In both examples, aColor is a colour value. I'm not sure whether they operate exactly like Delphi's standard TColor, where you specify the colour value in hex like this:- $bbggrr where bb, gg and rr are the values for Blue, Green and Red respectively. I think they may flip the Blue and Red around to the more traditional $rrggbb notation.
You also have another option for drawing on the TDXDraw surface. You can use a TDXImageList, that you load with images (this can be done at design time or dynamically at runtime). To get started, put the images into the TDXImageList at design time as its easier. Then, you can do this:-
[pascal]
dxImageList1.items[0].draw(dxdraw1.surface,xPos,yPos,pattern);
[/pascal]
I use a pattern value of 0 as I have no idea what it does yet. This will draw the image in the image list at position 0 to the surface with its top left corner at xPos,Ypos on the surface. There are lots of different variations on this method that allow you to incorporate alpha blending and other effects.
And last but not least, the TDXDraw surface also has a fairly standard TCanvas property allowing you to plot lines, text, arcs. etc.
[pascal]
with dXDraw1.Surface.Canvas do
begin
Brush.Style := bsClear;
Font.Color := clWhite;
Font.Size := 8;
Font.style:=[fsBold];
Font.name:='Courier New';
TextOut(0,0,'Hello World');
Release;
end;
[/pascal]
You must remember to release the canvas when you've finished using it.
So, bringing this all together, you might have something like this in a TDXTimer onTimer event:-
[pascal]
if dxdraw1.canDraw then
begin
dxdraw1.surface.fill(0); // Clear the draw area
dximagelist1.items[0].draw(dxdraw1.surface,0,0,0);
dximagelist1.items[1].draw(dxdraw1.surface,100,100,0);
with dxdraw1.surface.canvas do
begin
// Use the canvas here
release;
end;
dxdraw1.flip; // You must have doFlip in the options to use this
end;
[/pascal]
You don't have to use flip, but using it makes for a smoother display since the user only sees the new screen when you've finished drawing it. But you must have the doFlip option set in the TDXDraw options. If you are using unDelphiX, to enable hardware acceleration, you should have the following options set to true:- do3D, doDirectX7Mode and doHardware.
You may also want to check out all the examples that come with unDelphiX. They are quite useful.
I hope this helps.
:: AthenaOfDelphi :: My Blog :: My Software ::
He means that image is multiplied with a color.
Here's discussion about improved undelphix and how it can be done:
http://www.delphigamedev.com/forums/viewtopic.php?t=292
It makes this kind of command possible:
[pascal]DrawAlphaCol(Surface, DestRect, PatternIndex, RGB(0,255,0), Alpha);[/pascal]
That would draw grayscale image as green, red or blue image as black and so on...
Edit: Made this small demonstration
This uses only 1 TDXImageList item, only colors them with alpha weakening when going down.
Neat.
I figured he wanted something else, because after I posted I read about Netsoccer. But still, worth my time posting, because now I've learned something :-)
:: AthenaOfDelphi :: My Blog :: My Software ::
Bookmarks