Author Topic: Fast rotate Bitmap  (Read 5674 times)

hosune7845

  • Full Member
  • ***
  • Posts: 159
Fast rotate Bitmap
« on: January 05, 2016, 11:17:41 am »
Hi.

I need to rotate bitmap in my project.

But rotating speed is too slow to use..

Anyone know how to rotate a bitmap fast?

If can, I want to use TLazIntfImage!

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12984
  • FPC developer.
Re: Fast rotate Bitmap
« Reply #1 on: January 05, 2016, 11:27:44 am »
I did it once for 90 degrees you could use http://stackoverflow.com/questions/848025/rotating-bitmaps-in-code

A newer, lazarus compilable version of this code is in http://forum.lazarus.freepascal.org/index.php/topic,30556.msg194612.html#msg194612

but it is not for tlazintfimage, but for an own (included) imagetype.

hosune7845

  • Full Member
  • ***
  • Posts: 159
Re: Fast rotate Bitmap
« Reply #2 on: January 05, 2016, 11:47:34 am »
I did it once for 90 degrees you could use http://stackoverflow.com/questions/848025/rotating-bitmaps-in-code

A newer, lazarus compilable version of this code is in http://forum.lazarus.freepascal.org/index.php/topic,30556.msg194612.html#msg194612

but it is not for tlazintfimage, but for an own (included) imagetype.

Thank you.

I find one way, It works on PC, But doesn't work on arm-linux

Here's my code :
Code: Pascal  [Select][+][-]
  1. var
  2.   tmp: TBitmap;
  3.   src, dst: TLazIntfImage;
  4.   ImgHandle, ImgMaskHandle: THandle;
  5.   i, j, t, u, v: integer;
  6. begin
  7.   tmp := TBitmap.create;
  8.   tmp.Width := Image1.Picture.Bitmap.Height;
  9.   tmp.Height := Image1.Picture.Bitmap.Width;
  10.   dst := TLazIntfImage.Create(0, 0);
  11.   dst.LoadFromBitmap(tmp.Handle, tmp.MaskHandle);
  12.   src := TLazIntfImage.Create(0, 0);
  13.   src.LoadFromBitmap(Image1.Picture.Bitmap.Handle, Image1.Picture.Bitmap.MaskHandle);
  14.   u := Image1.Picture.Bitmap.width - 1;
  15.   v := Image1.Picture.Bitmap.height - 1;
  16.   for i := 0 to u do begin
  17.     t := u - i;
  18.     for j := 0 to v do
  19.       dst.Colors[j, t] := src.Colors[i, j];
  20.   end;
  21.   dst.CreateBitmaps(ImgHandle, ImgMaskHandle, false); // The error occurs on here.
  22.   tmp.Handle := ImgHandle;
  23.   tmp.MaskHandle := ImgMaskHandle;
  24.   dst.Free;
  25.   Image1.Picture.Bitmap.Assign(tmp);
  26.   tmp.Free;
  27.   src.Free;    
  28.  

The error is "Call by var for arg no. 2 has to match exactly: Got "Longlnt" expected "HBITMAP"
« Last Edit: January 06, 2016, 03:20:40 am by hosune7845 »

Thaddy

  • Hero Member
  • *****
  • Posts: 19636
  • Glad to be alive.
Re: Fast rotate Bitmap
« Reply #3 on: January 06, 2016, 01:32:01 pm »
If it is for windows use the plgblt api. That is very fast and standard windows.
Any "programmer" that knows only one programming language is not a programmer

jack616

  • Sr. Member
  • ****
  • Posts: 268
Re: Fast rotate Bitmap
« Reply #4 on: January 06, 2016, 01:48:41 pm »
just a thought;
do you need to actually need to rotate the bitmap - or would just changing the
output co-ordinates work?

 

TinyPortal © 2005-2018