Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:27+00:00 2026-06-01T20:20:27+00:00

I can get a 32-bit image to be displayed in TImage with GDIPlus that

  • 0

I can get a 32-bit image to be displayed in TImage with GDIPlus that has partial (masked) transparency but the alpha values are either 0 or 255 with no values in between. I have tried loading PngImage, 32-bit bitmaps and icons all produce the same… masked transparency but not full transparency.

Is there another way to get TImage to display a GDI+ graphic with full transparency as shown in the Desired Result image?

enter image description here
GDI Plus After Open

enter image description here
Desired Result

procedure TFormMain.Open1Click ( Sender: TObject );
// Load a GDIPlus Bitmap into TImage
var
  GPBitmap: TGPBitmap;
  iHBitmap: HBITMAP;
  iStatus: TStatus;
const
  TRANS_COLOR = clBlack;
begin

  if OpenPictureDialog1.Execute then
  begin

    FilePath := OpenPictureDialog1.FileName;
    begin

      GPBitmap := TGpBitmap.Create ( FilePath );
      try

        iStatus := GPBitmap.GetHBITMAP ( aclBlack, iHBitmap );
        // As best as I can determine from the internet, the GetHBitmap which is needed to assign a GPbitmap to TImage
        // does not hold an alphachannel, so loaded images alpha are either 0 or 255, but drawing with alphachannel values does work.
        if iStatus = Ok then
        begin

          Image1.Picture.Bitmap.Handle := iHBitmap;
          Image1.Picture.Bitmap.TransparentColor := Image1.Picture.Bitmap.Canvas.Pixels [ 0, Image1.Picture.Bitmap.Height - 1 ];
          StatusBar1.Panels [ 0 ].Text := FileCtrl.MinimizeName ( ExtractFileDir ( FilePath ), Canvas, 200 ); // Folder
          StatusBar1.Panels [ 1 ].Text := FileCtrl.MinimizeName ( ExtractFileName ( FilePath ), Canvas, 75 ); // Filename
          StatusBar1.Panels [ 2 ].Text := 'Width: ' + IntegerToString ( Image1.Picture.Bitmap.Width ); // Width
          StatusBar1.Panels [ 3 ].Text := 'Height: ' + IntegerToString ( Image1.Picture.Bitmap.Height ); // Height
          StatusBar1.Panels [ 4 ].Text := BitDepthToColorString ( GetPixelFormatSize ( GPBitmap.GetPixelFormat ) ); // Bitdepth

          Image1.Refresh;

        end;

      finally
        GPBitmap.Free;
      end;

    end;

  end;

end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:20:27+00:00Added an answer on June 1, 2026 at 8:20 pm

    What you need to do is to choose a background color that will blend with the surface that the image is drawn on when it is transferred. I.e. instead of

    iStatus := GPBitmap.GetHBITMAP ( aclBlack, iHBitmap );
    

    use

    iStatus := GPBitmap.GetHBITMAP(ColorRefToARGB(ColorToRGB(clBtnFace)), iHBitmap);
    

    if the image is on a default colored form for instance.

    At this point you already know that the image has no alpha channel, but it has been flattened using a suitable color. The Transparent.. properties of ‘TBitmap’ will not help with partial transparency. If you set the Transparent property of the TBitmap, it will still be like the first image of your question when you put it on a different colored background, probably with a nicer edge color. In any case, if you use it, do not forget to set the ‘TransparentColor’ to ‘clBtnFace’ instead of ‘clBlack’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is a bit of a newbie question but hoping I can get some
I have this bit of code that get the image i have picked from
I'm a bit lost on this one. How can I get an OutOfBounds? Is
I've played around quite a bit now, and can't seem to get variables to
I would like to have a MovieClip that has a bit of depth. I
I am a bit of a pickle right now: I have an image displayed
I'm using the Image control to display an 8-bit grayscale image that I process
Can get all triples with value null in specific field? All people with date_of_birth
You can get underground processes by ps ux I am searching a way to
You can get a list of databases using PRAGMA database_list or a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.