Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • Last Modified:

Alpha Blending

People Say The Alpha Blending Is Only Supported On 2K & XP Machines Only, I Know That Nothing Is Impossible.
So Being A Junior Programmer, I Can't Write A Function Which Would Give My Form An Alpha Blending Effect On 9X & Me Computers.
Could Any One Help Me In This One,Please.
0
Ahmad_R
Asked:
Ahmad_R
3 Solutions
 
LummieCommented:
It depends on what you want to Alphablend....

If it is 2 images then check this out
http://www.efg2.com/Lab/ImageProcessing/Tween.htm
or
http://delphi.icm.edu.pl/ftp/d30free/graph64.zip
There are various examples and libraries

Alternatively if its icons you want to put on a form, try using PNG and an Image component : http://pngdelphi.sourceforge.net/
This one works great but is a bit slow if you want to do things like large animations.

Hope this helps
0
 
Korsar_13Commented:
For Delphi, check Graphics32:
http://www.g32.org/graphics32/

Some of Graphics32 features include:
Fast per-pixel access up to 100 times faster compared to standard TCanvas/TBitmap;
Bitmap alpha blending (including per-pixel alpha blending);
Pixel, line and polygon antialiasing (combined with alpha blending);
Locking the bitmap for safe multithreading;
Enhanced scaling of bitmaps;
Affine transformations of bitmaps: rotations, scaling, etc. with sub-pixel accuracy;
Arbitrary projective transformations of bitmaps;
Flicker-free image displaying components with optimized double buffering;
Multiple customizable easy-to-use overlay layers;
A property editor for RGB and alpha channel loading;
Design-time loading of image formats supported by standard TPicture;
0
 
Slick812Commented:
hello Ahmad_R, ther are many components that will do this sort of thein, you can look at Torry's for some, but if you want to try the code, here is some that might do what you want



procedure TForm1.sbut_TestMergClick(Sender: TObject);
Type
  TpRGB = packed record
    b, g, r : Byte;
    end;
var
Bmp1RGB: ^TpRGB;
Bmp2RGB: ^TpRGB;
y, x, pic: Integer;
BlendFactor  : real;
FirstBmp, BlendBmp: TBitmap;
Amount,Amt: Real;
GboxDC: HDC;
begin
Amount := 0.50;
{Amount is the Blend ratio, se here to Half and half
from each image}
FirstBmp := TBitmap.Create;
BlendBmp := TBitmap.Create;
try
FirstBmp.LoadFromFile('C:\Stuff\First.bmp');
FirstBmp.PixelFormat  := pf24Bit;


BlendBmp.PixelFormat := pf24bit;
//BlendBmp.Canvas.Brush.Color := clRed;
BlendBmp.LoadFromFile('C:\Stuff\Blend.bmp');
BlendBmp.Width := FirstBmp.Width;
BlendBmp.Height := FirstBmp.Height;
{IMPORTANT BlendBmp and FirstBmp MUST have the same dimentions}

Amt := Amount;

BlendFactor := 1.0 - Amt;
  For y := 0 to FirstBmp.Height -1 do
    begin // y to height
    Bmp1RGB := FirstBmp.ScanLine[y];
    Bmp2RGB := BlendBmp.ScanLine[y];
    For x := 0 to FirstBmp.Width -1 do
      Begin
      Bmp2RGB.r := ROUND(BlendFactor * Bmp2RGB.r + Amt * Bmp1RGB.r);
      Bmp2RGB.g := ROUND(BlendFactor * Bmp2RGB.g  + Amt * Bmp1RGB.g);
      Bmp2RGB.b := ROUND(BlendFactor * Bmp2RGB.b  + Amt * Bmp1RGB.b);
      Inc(Bmp1RGB);
      Inc(Bmp2RGB);
      End;
    end; //y to height
Canvas.Draw(3,70, BlendBmp);
finally
FirstBmp.Free;
BlendBmp.Free;
end;
end;


- - - - - - - - - - - - - - - - - - - - - - -
scanline is useful, but not easy to learn
ask questions if you need more Info
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Slick812Commented:
should be


BlendBmp.LoadFromFile('C:\Stuff\Blend.bmp');
BlendBmp.PixelFormat := pf24bit;
0
 
CleanupPingCommented:
Ahmad_R:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
kacorretiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       split points between Lummie, Korsar_13 and Slick812
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now