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

  • SEARCH
  • Home
  • 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 8045631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:36:35+00:00 2026-06-05T05:36:35+00:00

I have a routine that takes screenshots (TBitmap), I need to add drop-shadow to

  • 0

I have a routine that takes screenshots (TBitmap), I need to add drop-shadow to the final TBitmap/image, I have this code (which used to work but…) something isn’t right, the drop-shadow simply isn’t drawn:

// --------------------------------------------------------------------- //
procedure TakeScreenshot();
var
   lCapRect : TRect;
   DestBitmap : TBitmap;
begin
     // Take the screenshot & assign it to DestBitmap
     // ...

     // Add the drop shadow to DestBitmap
     DestBitmap.Width  := DestBitmap.Width + 6;
     DestBitmap.Height := DestBitmap.Height + 6;

     PaintShadow(DestBitmap.Canvas, lCapRect);
end;
// --------------------------------------------------------------------- //
procedure PaintShadow(ACanvas : TCanvas; ARect : TRect);
var
   AColor         : TColor;
   i, iMax        : Integer;
   h1, h2, v1, v2 : Integer;
begin
     AColor := ACanvas.Brush.Color;
     iMax   := 6;
     h1     := ARect.Left;
     h2     := ARect.Right;
     v1     := ARect.Top;
     v2     := ARect.Bottom;

     with ACanvas do
     begin
      for i := iMax downto 0 do
      begin
           ACanvas.Pen.Mode := pmMask;
           Pen.Color        := DarkenColorBy(AColor, ((iMax - i) * 4 + 10));

           MoveTo(h1 + 4{i}, v2 + i);
           LineTo(h2 + i + 1, v2 + i);
      end;    // for

      for i := iMax downto 0 do
      begin
           ACanvas.Pen.Mode := pmMask;
           Pen.Color        := DarkenColorBy(AColor, ((iMax - i) * 4 + 10));

           MoveTo(h2 + i, v1 + 4{i});
           LineTo(h2 + i, v2 + i);
      end;    // for
     end;    // with
end;
// --------------------------------------------------------------------- //
function Max(const A, B: Integer): Integer;
begin
     if (A > B) then
    Result  := A
     else
     Result := B;
end;
// --------------------------------------------------------------------- //
function DarkenColorBy(BaseColor : TColor; Amount : Integer) : TColor;
begin
     Result := RGB(Max(GetRValue(ColorToRGB(BaseColor)) - Amount, 0),
           Max(GetGValue(ColorToRGB(BaseColor)) - Amount, 0),
           Max(GetBValue(ColorToRGB(BaseColor)) - Amount, 0));
end;

My question is: How can I fix this (OR anyone know a simple way to add dropshadow to a TBitmap)?

The final image is meant to be saved as bmp/jpg, not shown in a TImage, so I really need to add drop shadow to the image itself.

PS. I’m using Delphi 7 Pro, my app is restricted to Windows XP or later

EDIT

lCapRect depends on the settings (whether I’m capturing the active monitor, window or all the desktop monitors), but let’s say it’s calculated this way:

lCapRect.Right  := Screen.DesktopLeft + Screen.DesktopWidth;
lCapRect.Bottom := Screen.DesktopTop + Screen.DesktopHeight;
lCapRect.Left   := Screen.DesktopLeft;
lCapRect.Top    := Screen.DesktopTop;

The bitmap does contain the screenshot (+ 6 pixels added to the bottom & right sides to make room for the dropshadow), it’s just that the drop shadow drawing doesn’t happen

  • 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-05T05:36:36+00:00Added an answer on June 5, 2026 at 5:36 am

    You haven’t shown how you are calculating lCapRect. For not drawing off the bitmap regarding your PaintShadow procedure, it has to be smaller than the bitmap, example:

    lCapRect := DestBitmap.Canvas.ClipRect;
    
    // Add the drop shadow to DestBitmap
    DestBitmap.Width  := DestBitmap.Width + 6;
    DestBitmap.Height := DestBitmap.Height + 6;
    
    PaintShadow(DestBitmap.Canvas, lCapRect);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some python code that: Takes a BLOB from a database which is
I have a routine that examines thousands of records looking for discrepancies. This can
I have a routine that takes a list of strings as a parameter, but
I have an Oracle PL/SQL routine that takes a BLOB as a parameter. The
I have this routine which is called onmouseover of a certain element. I want
We have an application that runs a routine like: protected string _largeFile; Execute() //this
I have a program that takes an image and writes that out to a
I have a custom routing application that takes information for a route from google
I have a routine that uses a HttpURLConnection to upload a file via a
I have a routine that dynamically changes a select list's selected option when the

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.