Results 1 to 7 of 7

Thread: Changing RGB

  1. #1

    Changing RGB

    Hello. How im able to draw pictures with different rgb's?
    www.netsoccer.biz

  2. #2

    Changing RGB

    You?¢_Tre question doesn?¢_Tt make much sense, do you mean using palettes or color modulation or something?

  3. #3

    Changing RGB

    I'm assuming that you are meaning draw a greyscale image using an RGB color?

  4. #4

    Re: Changing RGB

    Quote Originally Posted by Jonne
    Hello. How im able to draw pictures with different rgb's?
    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.

  5. #5
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2

    Re: Changing RGB

    Quote Originally Posted by Jonne
    Hello. How im able to draw pictures with different rgb's?
    Hi 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 ::

  6. #6

    Changing RGB

    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.


  7. #7
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2

    Changing RGB

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •