Code: Alles auswählen
type
  pBitmap=^TBitmap;
  pCanvasOPBitmap=^TCanvasOPBitmap;
 
//... usw.
 
procedure ScaleBitmap(Bitmap,Value:pBitmap;var retwidth,retheight:Integer);
var x,y:Integer;
begin
  Bitmap^.Canvas.Brush.Color:=clblack;
  Bitmap^.Canvas.FillRect(Rect(0,0,Bitmap^.width,Bitmap^.height));
  if not Assigned(Value^) then exit;
  if(Value^.height=0)or(Value^.width=0)then exit;
  retwidth:=Bitmap^.height*Value^.Width div Value^.Height;
  if retwidth<Bitmap^.width then retheight:=Bitmap^.height else
    begin
      retheight:=Bitmap^.width*Value^.Height div Value^.Width;
      retwidth:=Bitmap^.width;
    end;
  x:=(Bitmap^.width-retwidth)div 2;
  y:=(Bitmap^.height-retheight)div 2;
  Bitmap^.Canvas.StretchDraw(Rect(x,y,x+retwidth,y+retheight),Value^);
end;
 
procedure ScaleOPBitmap(Bitmap,Value:pCanvasOPBitmap;var retwidth,retheight:Integer);
var x,y:Integer;
begin
  Bitmap^.Canvas.Brush.Color:=clblack;
  Bitmap^.Canvas.FillRect(Rect(0,0,Bitmap^.width,Bitmap^.height));
  if not Assigned(Value^) then exit;
  if(Value^.height=0)or(Value^.width=0)then exit;
  retwidth:=Bitmap^.height*Value^.Width div Value^.Height;
  if retwidth<Bitmap^.width then retheight:=Bitmap^.height else
    begin
      retheight:=Bitmap^.width*Value^.Height div Value^.Width;
      retwidth:=Bitmap^.width;
    end;
  x:=(Bitmap^.width-retwidth)div 2;
  y:=(Bitmap^.height-retheight)div 2;
  Value^.Canvas.Resample(retwidth,retheight);
  Bitmap^.Canvas.CopyRect(Rect(x,y,x+retwidth,y+retheight),Value^.Canvas,Rect(0,0,Value^.Width,Value^.Height));
end;
 
 
procedure TForm1.Button2Click(Sender: TObject);
const w = 2000;
const h = 2000;
var
  SrcIntfImg: TLazIntfImage;
  T1,T2: TBitmap;
  OP,OP1: TCanvasOPBitmap;
  fOP :TOPPicture;
  s, e: Cardinal;
  File1:string;
  hw,hh:Integer;
  ImgHandle,
  ImgMaskHandle: HBitmap;
begin
 
  File1:=ExtractFilePath(Application.ExeName)+'Test1.bmp';
 
  Image1.Picture.Bitmap.Width:=w;
  Image1.Picture.Bitmap.Height:=h;
 
  //OpBitmap
  OP := TCanvasOPBitmap.Create;
  OP1 := TCanvasOPBitmap.Create;
  fOP := TOPPicture.Create;
 
  OP1.Width:=w;
  OP1.Height:=h;
 
  s := GetTickCount;
  fOP.LoadFromFile(File1);
  fOP.Bitmap.PixelFormat:=pf32bit;
  OP:=fOP.Bitmap;
  ScaleOPBitmap(@OP1,@OP,hw,hh);
  lazbridge32.OpBitmapPaint32(OP1,Image1.Canvas,0,0);
 
  e := GetTickCount - s;
  Edit1.Text:=InttoStr(e);
 
 
  OP.Free;
  Op1.Free;
 
  //TBitmap
 
  T1:=TBitmap.Create;
  T2:=TBitmap.Create;
  SrcIntfImg:=TLazIntfImage.Create(0,0);
 
  T2.Width:=w;
  T2.Height:=h;
 
  s := GetTickCount;
 
  T1.LoadFromFile(File1);
  ScaleBitmap(@T2,@T1,hw,hh);
 
  SrcIntfImg.LoadFromBitmap(T2.Handle,T2.MaskHandle);
 
  SrcIntfImg.CreateBitmaps(ImgHandle, ImgMaskHandle, false);
  T2.Handle := ImgHandle;
  T2.MaskHandle := ImgMaskHandle;
 
 
  Image1.canvas.Draw(0,0,T2);
 
  e := GetTickCount - s;
  Edit2.Text:=InttoStr(e);
 
  T1.Free;
  T2.Free;
 
  Edit3.Text:='';
  Edit4.Text:='';
  Edit5.Text:='';
 
end;Dies sind die Werte:
OPBitmap:843ms
TBitmap:109ms

 hier eine 64bit Version von OpBitmap
 hier eine 64bit Version von OpBitmap
 Verein
Verein 
 Links
Links Suche
Suche