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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:06:03+00:00 2026-06-10T17:06:03+00:00

Good afternoon. I’m working on a drawing program that allows the user to drag

  • 0

Good afternoon.

I’m working on a drawing program that allows the user to drag and drop TImages loaded with a Bitmap over a canvas. (In a Firemonkey HD application in RAD Studio XE2) The user can then change x and y scales and rotation before saving the image.
All TImages are kept in a list and this list is then written to the underlying canvas using this simple procedure:

  for i := 0 to DroppedList.Count - 1 do
  begin
    AImage := DroppedList[i];
    SourceRect.Left := 0;
    SourceRect.Right := AImage.Bitmap.Width;
    SourceRect.Top := 0;
    Sourcerect.Bottom := AImage.Bitmap.Height;

    TargetRect.Left := AImage.Position.X;
    TargetRect.Right := AImage.Position.X + AImage.Bitmap.Width;
    TargetRect.Top := AImage.Position.Y;
    TargetRect.Bottom := AImage.Position.Y + AImage.Bitmap.Height;

    with FImage.Bitmap do
    begin
      Canvas.BeginScene;
      Canvas.DrawBitmap(AImage.Bitmap, SourceRect, TargetRect, 1, True);
      Canvas.EndScene;
      BitmapChanged
    end;
  end;

  FImage.Bitmap.SaveToFile('test.bmp');

The problem with this is that transformations to the scale and rotation of the images that are visible in the window are not taken into account by DrawBitmap, and are lost when saving.
I am looking for a way to apply the transformations to the bitmap before drawing it to the background.
I was unable to find any info on this, so i was hoping someone here could help.

Thank you,
Daniël

  • 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-10T17:06:04+00:00Added an answer on June 10, 2026 at 5:06 pm

    the problem seems to be that the Scaling and the Rotation are applyed to a source TImage. In this “source TImage”, the transformations are not done to the bitmap but rather at the TImage level (beause it’s a TControl and as all TControl they can be scaled and rotated). Later you copy the source Bitmap elsewhere, but actually this Bitmap has never changed.

    So would have to rotate and scale the bitmap in the loop, according to the settings in the source TImage:

    with FImage.Bitmap do
    begin
      Canvas.BeginScene;     
      LBmp := TBitmap.Create;
      try
        // create a copy on which transformations will be applyed
        LBmp.Assign(AImage.Bitmap); 
        // rotate the local bmp copy according to the source TImage.
        if AImage.RotationAngle <> 0 then
          LBmp.Rotate( AImage.RotationAngle);
        // scale the local bmp copy...
        If AImage.Scale.X <> 1 
          then ;
        Canvas.DrawBitmap(LBmp, SourceRect, TargetRect, 1, True);
      finally
        LBmp.Free;
        Canvas.EndScene;
        BitmapChanged
      end;
    end;
    

    This simple code sample explains well the problem. For example, RotatationAngle is a property of AImage and not of AImage.Bitmap.

    A workaround that would avoid to implement the transformations would be to use TControl.MakeScreenshot(). (to be verified, this coulds fail)

    with FImage.Bitmap do
    begin
      Canvas.BeginScene;
      LBmpInclTranformations := AImage.MakeScreenShot;
      Canvas.DrawBitmap(LBmpInclTranformations, SourceRect, TargetRect, 1, True);
      Canvas.EndScene;
      BitmapChanged
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon, I'm working on a project for my company to run an update
Good afternoon, I'm having a problem with a section of code I'm working on
Good afternoon all, I am building a function that takes a string as input,
Good afternoon I have a table that has customer id, name, computer, laptop, blah,
Good afternoon all. I am aware that if we close() an java.io.OutputStream , it
Good afternoon all, I was wondering why is it that android.app.Activity.onTrimMemory couldn't be overridden?
Good Afternoon, I have a Joomla! template that keeps throwing up a pop up
Good afternoon all, I was taught that when a function returns, The variables (within
Good afternoon people's I have built a jquery plugin that I use on my
Good afternoon, does anyone know of a library that would allow me to read

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.