Sayfayı Yazdır | Pencereyi Kapat

Bitmap SmoothResize

Nereden Yazdırıldığı: Datakent
Kategori: Diğer bölümler
Forum Adı: Borland Delphi
Forum Tanımlaması: Borland Delphi ile ilgili soru / sorun / paylaşım bölümü
URL: http://forum.datakent.com/forum_posts.asp?TID=1827
Tarih: 28.Mart.2024 Saat 23:02


Konu: Bitmap SmoothResize
Mesajı Yazan: murat turan
Konu: Bitmap SmoothResize
Mesaj Tarihi: 31.Ekim.2009 Saat 10:24

procedure JxSmoothResize(NewWidth, NewHeight: Cardinal; var Src: TBitmap);
var
  x, y, xP, yP, yP2, xP2: integer;
  Read, Read2: PByteArray;
  t, z, z2, iz2: integer;
  pc: PBytearray;
  w1, w2, w3, w4: integer;
  Col1r, col1g, col1b, Col2r, col2g, col2b: byte;
  Dst:TBitmap;
begin
  Dst := TBitmap.Create;
  Dst.PixelFormat := pf24Bit;
  Dst.Width  := NewWidth;
  Dst.Height := NewHeight;

  xP2 := ((src.Width - 1) shl 15) div Dst.Width;
  yP2 := ((src.Height - 1) shl 15) div Dst.Height;
  yP := 0;
  for y := 0 to Dst.Height - 1 do
  begin
    xP := 0;
    Read := src.ScanLine[yP shr 15];
    if yP shr 16 < src.Height - 1 then
      Read2 := src.ScanLine[yP shr 15 + 1]
    else
      Read2 := src.ScanLine[yP shr 15];
    pc := Dst.scanline[y];
    z2 := yP and $7FFF;
    iz2 := $8000 - z2;
    for x := 0 to Dst.Width - 1 do
    begin
      t := xP shr 15;
      Col1r := Read[t * 3];
      Col1g := Read[t * 3 + 1];
      Col1b := Read[t * 3 + 2];
      Col2r := Read2[t * 3];
      Col2g := Read2[t * 3 + 1];
      Col2b := Read2[t * 3 + 2];
      z := xP and $7FFF;
      w2 := (z * iz2) shr 15;
      w1 := iz2 - w2;
      w4 := (z * z2) shr 15;
      w3 := z2 - w4;
      pc[x * 3 + 2] :=
        (Col1b * w1 + Read[(t + 1) * 3 + 2] * w2 +
        Col2b * w3 + Read2[(t + 1) * 3 + 2] * w4) shr 15;
      pc[x * 3 + 1] :=
        (Col1g * w1 + Read[(t + 1) * 3 + 1] * w2 +
        Col2g * w3 + Read2[(t + 1) * 3 + 1] * w4) shr 15;
      pc[x * 3] :=
        (Col1r * w1 + Read2[(t + 1) * 3] * w2 +
        Col2r * w3 + Read2[(t + 1) * 3] * w4) shr 15;
      Inc(xP, xP2);
    end;
    Inc(yP, yP2);
  end;

  try
    Src.Assign(Dst);
  finally
    Dst.Free;
  end;
end;



-------------
http://www.kasatakip.com - Kasa Takip  |  http://www.caritakip.com - Cari Takip  |  http://www.evraktakip.com - Evrak Takip  |  http://www.etasqlmobil.com - ETA SQL Mobil



Sayfayı Yazdır | Pencereyi Kapat