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 6561343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:34:30+00:00 2026-05-25T13:34:30+00:00

Usually I allow my users to place an image in the main form. Because

  • 0

Usually I allow my users to place an image in the main form.

Because some images cause to much noise, I would like to smooth those a bit.

I usually do some transparency in the images that I give as defaults.

How can I do this automatically as the user selects a new image, or as I load it?

  • 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-05-25T13:34:31+00:00Added an answer on May 25, 2026 at 1:34 pm

    Add a trackbar to a TOpenPictureDialog derivative setting the transparancy level:

    unit OpenFadedPictureDialog;
    
    interface
    
    uses
      Classes, Controls, ExtDlgs, ComCtrls, StdCtrls, Windows, Graphics, ExtCtrls;
    
    type
      TOpenFadedPictureDialog = class(TOpenPictureDialog)
      private
        FFader: TTrackBar;
        FFaderLabel: TLabel;
        FBlendFunc: BLENDFUNCTION;
        FTimer: TTimer;
        procedure Delayed(Sender: TObject);
        procedure FaderChanged(Sender: TObject);
        procedure UpdateImage;
      protected
        procedure DoShow; override;
        procedure DoSelectionChange; override;
      public
        constructor Create(AOwner: TComponent); override;
        function Picture: TPicture;
        function TransparancyLevel: Byte;
      end;
    
    implementation
    
    { TOpenFadedPictureDialog }
    
    resourcestring
      SFaderHint = 'Track bar to set image transparancy.';
      SFaderLabelCaption = 'Image transparancy:';
    
    constructor TOpenFadedPictureDialog.Create(AOwner: TComponent);
    begin
      inherited Create(Owner);
      FFaderLabel := TLabel.Create(Self);
      FFaderLabel.Name := 'FaderLabel';
      FFaderLabel.Align := alTop;
      FFaderLabel.Caption := SFaderLabelCaption;
      FFader := TTrackBar.Create(Self);
      FFader.Name := 'FaderTrackBar';
      FFader.Align := alTop;
      FFader.Height := 25;
      FFader.TickStyle := tsNone;
      FFader.PageSize := 25;
      FFader.Max := 255;
      FFader.Position := 127;
      FFader.Hint := SFaderHint;
      FFader.OnChange := FaderChanged;
      FBlendFunc.BlendOp := AC_SRC_OVER;
      FBlendFunc.SourceConstantAlpha := 127;
      FTimer := TTimer.Create(Self);
      FTimer.Enabled := False;
      FTimer.Interval := 100;
      FTimer.OnTimer := Delayed;
    end;
    
    procedure TOpenFadedPictureDialog.Delayed(Sender: TObject);
    begin
      FTimer.Enabled := False;
      FBlendFunc.SourceConstantAlpha := FFader.Position;
      if (ImageCtrl.Picture <> nil) and (ImageCtrl.Picture.Graphic <> nil) then
        ImageCtrl.Picture.LoadFromFile(FileName);
      UpdateImage;
    end;
    
    procedure TOpenFadedPictureDialog.DoSelectionChange;
    begin
      inherited DoSelectionChange;
      UpdateImage;
    end;
    
    procedure TOpenFadedPictureDialog.DoShow;
    begin
      with ImageCtrl do
      begin
        Picture := nil;
        Align := alTop;
        Anchors := [akLeft, akTop, akRight, akBottom];
        Height := Height - FFaderLabel.Height + FFader.Height - 15;
        FFaderLabel.Parent := Parent;
        FFader.Parent := Parent;
      end;
      inherited DoShow;
    end;
    
    procedure TOpenFadedPictureDialog.FaderChanged(Sender: TObject);
    begin
      FTimer.Enabled := False;
      FTimer.Enabled := True;
    end;
    
    function TOpenFadedPictureDialog.Picture: TPicture;
    begin
      Result := ImageCtrl.Picture;
    end;
    
    function TOpenFadedPictureDialog.TransparancyLevel: Byte;
    begin
      Result := FBlendFunc.SourceConstantAlpha;
    end;
    
    procedure TOpenFadedPictureDialog.UpdateImage;
    var
      Src: TBitmap;
      Dst: TBitmap;
    begin
      if (ImageCtrl.Picture <> nil) and (ImageCtrl.Picture.Graphic <> nil) then
      begin
        Src := TBitmap.Create;
        Dst := TBitmap.Create;
        try
          Src.Width := ImageCtrl.Picture.Width;
          Src.Height := ImageCtrl.Picture.Height;
          Dst.Width := Src.Width;
          Dst.Height := Src.Height;
          Src.Canvas.Draw(0, 0, ImageCtrl.Picture.Graphic);
          AlphaBlend(Dst.Canvas.Handle, 0, 0, Dst.Width, Dst.Height,
            Src.Canvas.Handle, 0, 0, Src.Width, Src.Height, FBlendFunc);
          ImageCtrl.Picture.Graphic := Dst;
        finally
          Dst.Free;
          Src.Free;
        end;
      end;
    end;
    
    end.
    

    Create this dialog to obtain the user’s desired transparancy level after execution with the TransparancyLevel function, or assign the chosen picture to the image on your main form:

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      with TOpenFadedPictureDialog.Create(nil) do
        try
          if Execute then
            Image1.Picture := Picture;
        finally
          Free;
        end;
    end;
    

    Example image of customized common dialog:

    Customized common dialog

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

Sidebar

Related Questions

I know that more-dynamic-than-Java languages, like Python and Ruby, often allow you to place
Usually we define iis web sites which allow anonymous authentication to run under the
Usually when I need to fork in C, I do something like this: pid_t
Usually when defining a DAO, you would have a setter for the datasource on
I'm building a community website. Users will login and logout as usually. I use
I am planning to allow users to generate .POT files/.PO files through a PHP
I would appreciate some thoughts here, we have globalized all the static content on
Is there any way to allow non-Administrator users to install, upgrade or uninstall an
Because my time is limited I can usually only focus on one or two
I need to traverse a tree quickly, and I would like to do it

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.