Results 1 to 3 of 3

Thread: Make semi-transparent images

  1. #1

    Make semi-transparent images

    I use the following code to draw an image:
    Code:
    Image1.Transparent := True;
    Bufferbox.Canvas.Draw(0, 0, Image1.Picture.Bitmap);
    The background color, that will became invisible, is purple.
    My question is this: Think if you have a torch then you want the flames have like 50% opacity so you can see through them. But when I paint the torch and it's flames with a yellow color with the 50% opacity the image looks fine until I run the program because then the torch will have purple flames!
    I hope I have explained this propely, if not askwhat the hell I meen!

  2. #2

    Make semi-transparent images

    The process you describe is called alpha-blending, and the standard TCanvas.Draw method does not support any kind of alpha blending.

    A couple of solutions for you.
    - Use one of the libraries that give you 2D graphics using the 3D capabilities of your video card via Direct3D or OpenGL. Such libraries include Asphyre, GameVision and Omega.
    - Use GDI+. It is used by Windows XP to draw the fading menus, to name one example.
    - Libraries such as GraphicsEx or GSoft that provide alpha-blending functionality.

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Make semi-transparent images

    If you plan on using a major API for your graphics, you can look at using the alpha channel (some libraries or component suites support it others don't). In some graphics modes you have RGBA or ARGB, etc... this will take that 4th byte(in a 32bit color mode) of video data and use it to do the alpha blending on that pixel. Could this be what you are sugesting aswell? Keep in mind that this is relatively harder to produce since your sprite or torch image will be seen and possibly only stored in RGB format.
    Jason McMillen
    Pascal Game Development
    Co-Founder





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
  •