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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:22:21+00:00 2026-06-01T08:22:21+00:00

When i call canvas.stretchdraw with a bitmap, the bitmap will be mirrored/flipped when left>right.

  • 0

When i call canvas.stretchdraw with a bitmap, the bitmap will be mirrored/flipped when left>right. This does not happen for a PNG. Is this a bug? What can I do to fix it?

To replicate, try this code:

procedure TForm1.TestStretchdraw;
var
  vBMP: TBitmap;
  vPNG: TPNGImage;
  X0,Y0,X1,Y1 : integer;
  R : TRect;

  procedure FlipRect;
  var
    T : integer;
  begin
    T := R.Left;
    R.Left := R.Right;
    R.Right := T;
  end;

begin
  vBMP := TBitmap.Create;
  vPNG := TPNGImage.Create;
  try
    vBMP.LoadFromFile('c:\temp\pic\pic.bmp');
    vPNG.LoadFromFile('c:\temp\pic\pic.png');

    X0 := 0;
    Y0 := 0;
    X1 := X0 + vBMP.Width;
    Y1 := Y0 + vBMP.Height;
    R := Rect(X0,Y0,X1,Y1);
    FlipRect;
    Canvas.StretchDraw(R,vBMP); //This image will be drawn mirrored

    X0 := vBMP.Width+10;
    Y0 := 0;
    X1 := X0 + vPNG.Width;
    Y1 := Y0 + vPNG.Height;
    R := Rect(X0,Y0,X1,Y1);
    FlipRect;
    Canvas.StretchDraw(R,vPNG); //This will not
  finally
    vPNG.Free;
    vBMP.Free;
  end;
end;

(but replace my testimages with some of your own)

  • 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-01T08:22:23+00:00Added an answer on June 1, 2026 at 8:22 am

    Here I wrote a function that flips a png without any libraries like Gr32. Transparency remains in the flipped PNG.

    procedure FlipPNG(aSource, aDest: TPngImage);
    var
      X, Y: Integer;
      AlphaPtr: PByteArray;
      RGBLine: pRGBLine;
      PalleteLine: PByteArray;
      AlphaPtrDest: PByteArray;
      RGBLineDest: pRGBLine;
      PalleteLineDest: PByteArray;
    begin
      aDest.Assign(aSource);
    
      if (aSource.Header.ColorType = COLOR_PALETTE) or
         (aSource.Header.ColorType = COLOR_GRAYSCALEALPHA) or
         (aSource.Header.ColorType = COLOR_GRAYSCALE) then
      begin
        for y := 0 to aSource.Height - 1 do
        begin
          AlphaPtr := aSource.AlphaScanline[y];
          PalleteLine := aSource.Scanline[y];
          AlphaPtrDest := aDest.AlphaScanline[y];
          PalleteLineDest := aDest.Scanline[y];
          for x := 0 to aSource.Width - 1 do
          begin
            PalleteLineDest^[aSource.Width - x -1] := PalleteLine^[x];
            if Assigned(AlphaPtr) then
              AlphaPtrDest^[aSource.Width - x -1] := AlphaPtr^[x];
          end;
        end;
      end else
      if (aSource.Header.ColorType = COLOR_RGBALPHA) or
         (aSource.Header.ColorType = COLOR_RGB) then
      begin
        for y := 0 to aSource.Height - 1 do
        begin
          AlphaPtr := aSource.AlphaScanline[y];
          RGBLine := aSource.Scanline[y];
          AlphaPtrDest := aDest.AlphaScanline[y];
          RGBLineDest := aDest.Scanline[y];
          for x := 0 to aSource.Width - 1 do
          begin
            RGBLineDest^[aSource.Width - x -1] := RGBLine^[x];
            if Assigned(AlphaPtr) then
              AlphaPtrDest^[aSource.Width - x -1] := AlphaPtr^[x];
          end;
        end;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a script, which manipulates with canvas. I call it like this: namespace.module.do(canvas, paramString);
I draw a bitmap onto a canvas using the following call: _playerImage = BitmapFactory.decodeResource(getResources(),
This class use to draw ball but its onDraw() function not call so ball
I call the following function with a mouseover event but it's not working. My
I call this a flash meeting, but maybe there is another more appropriate name.
I have a Canvas (lets call it the Drop Box) which users can drag
So I'm trying to work on a Canvas demo, and I want this square
I have a canvas element on a page. I call canvas.toDataURL() and now have
Here's my code that deals with adding an image to the canvas. What this
In my FB app I am making a call to FB.Canvas.setSize(); to fit 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.