Changeset 208 for trunk


Ignore:
Timestamp:
May 8, 2020, 6:51:18 PM (5 years ago)
Author:
chronos
Message:
  • Fixed: Replaced drawing using Bitmap ScanLine by TPixelPointer to suppress portable symbol warning and to be unified with similar existing functions.
Location:
trunk/Packages/CevoComponents
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/EOTButton.pas

    r188 r208  
    4747begin
    4848  RegisterComponents('C-evo', [TEOTButton]);
    49 end;
    50 
    51 procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h, Color0,
    52   Color2: integer);
    53 // Src is template
    54 // B channel = Color0 amp
    55 // G channel = background amp (old Dst content), 128=original brightness
    56 // R channel = Color2 amp
    57 type
    58   TPixel = array [0 .. 2] of Byte;
    59 var
    60   ix, iy, amp0, amp1, trans, Value: integer;
    61   SrcLine, DstLine: ^TPixel;
    62 begin
    63   Src.BeginUpdate;
    64   Dst.BeginUpdate;
    65   for iy := 0 to h - 1 do
    66   begin
    67     SrcLine := Src.ScanLine[ySrc + iy] + xSrc * (Src.RawImage.Description.BitsPerPixel shr 3);
    68     DstLine := Dst.ScanLine[yDst + iy] + xDst * (Dst.RawImage.Description.BitsPerPixel shr 3);
    69     for ix := 0 to w - 1 do
    70     begin
    71       trans := SrcLine[0] * 2; // green channel = transparency
    72       amp0 := SrcLine[1] * 2;
    73       amp1 := SrcLine[2] * 2;
    74       if trans <> $FF then
    75       begin
    76         Value := (DstLine[0] * trans + (Color2 shr 16 and $FF) * amp1
    77           + (Color0 shr 16 and $FF) * amp0) div $FF;
    78         if Value < 256 then
    79           DstLine[0] := Value
    80         else
    81           DstLine[0] := 255;
    82         Value := (DstLine[1] * trans + (Color2 shr 8 and $FF) * amp1
    83           + (Color0 shr 8 and $FF) * amp0) div $FF;
    84         if Value < 256 then
    85           DstLine[1] := Value
    86         else
    87           DstLine[1] := 255;
    88         Value := (DstLine[2] * trans + (Color2 and $FF) * amp1 +
    89           (Color0 and $FF) * amp0) div $FF;
    90         if Value < 256 then
    91           DstLine[2] := Value
    92         else
    93           DstLine[2] := 255;
    94       end;
    95       SrcLine := Pointer(SrcLine) + (Src.RawImage.Description.BitsPerPixel shr 3);
    96       DstLine := Pointer(DstLine) + (Dst.RawImage.Description.BitsPerPixel shr 3);
    97     end;
    98   end;
    99   Src.EndUpdate;
    100   Dst.EndUpdate;
    10149end;
    10250
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r206 r208  
    3636  overload;
    3737procedure MakeBlue(dst: TBitmap; x, y, Width, Height: Integer);
    38 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h: integer);
     38procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height: Integer);
    3939procedure ImageOp_BCC(dst, Src: TBitmap;
    40   xDst, yDst, xSrc, ySrc, Width, Height, Color1, Color2: integer);
    41 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: integer);
     40  xDst, yDst, xSrc, ySrc, Width, Height, Color1, Color2: Integer);
     41procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height,
     42  Color0, Color2: Integer);
     43procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);
    4244function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer;
    4345  SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload;
     
    555557end;
    556558
    557 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h: Integer);
     559procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height: Integer);
    558560// Src is template
    559561// X channel = background amp (old Dst content), 128=original brightness
     
    567569  Assert(dst.PixelFormat = pf24bit);
    568570  if xDst < 0 then begin
    569     w := w + xDst;
     571    Width := Width + xDst;
    570572    xSrc := xSrc - xDst;
    571573    xDst := 0;
    572574  end;
    573575  if yDst < 0 then begin
    574     h := h + yDst;
     576    Height := Height + yDst;
    575577    ySrc := ySrc - yDst;
    576578    yDst := 0;
    577579  end;
    578   if xDst + w > dst.Width then
    579     w := dst.Width - xDst;
    580   if yDst + h > dst.Height then
    581     h := dst.Height - yDst;
    582   if (w < 0) or (h < 0) then
     580  if xDst + Width > dst.Width then
     581    Width := dst.Width - xDst;
     582  if yDst + Height > dst.Height then
     583    Height := dst.Height - yDst;
     584  if (Width < 0) or (Height < 0) then
    583585    exit;
    584586
     
    587589  PixelDst := PixelPointer(Dst, xDst, yDst);
    588590  PixelSrc := PixelPointer(Src, xSrc, ySrc);
    589   for Y := 0 to h - 1 do begin
    590     for X := 0 to w - 1 do  begin
     591  for Y := 0 to Height - 1 do begin
     592    for X := 0 to Width - 1 do  begin
    591593      Brightness := PixelSrc.Pixel^.B; // One byte for 8-bit color
    592594      test := (PixelDst.Pixel^.R * Brightness) shr 7;
     
    616618
    617619procedure ImageOp_BCC(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height,
    618   Color1, Color2: integer);
     620  Color1, Color2: Integer);
    619621// Src is template
    620622// B channel = background amp (old Dst content), 128=original brightness
     
    622624// R channel = Color2 amp, 128=original brightness
    623625var
    624   ix, iy, amp1, amp2, trans, Value: integer;
    625   SrcPixel, DstPixel: TPixelPointer;
     626  ix, iy, amp1, amp2, trans, Value: Integer;
     627  SrcPixel: TPixelPointer;
     628  DstPixel: TPixelPointer;
    626629begin
    627630  if xDst < 0 then begin
     
    673676  Src.EndUpdate;
    674677  dst.EndUpdate;
     678end;
     679
     680procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height,
     681  Color0, Color2: Integer);
     682// Src is template
     683// B channel = Color0 amp
     684// G channel = background amp (old Dst content), 128=original brightness
     685// R channel = Color2 amp
     686var
     687  ix, iy, amp0, amp1, trans, Value: integer;
     688  SrcPixel: TPixelPointer;
     689  DstPixel: TPixelPointer;
     690begin
     691  Src.BeginUpdate;
     692  Dst.BeginUpdate;
     693  SrcPixel := PixelPointer(Src, xSrc, ySrc);
     694  DstPixel := PixelPointer(Dst, xDst, yDst);
     695  for iy := 0 to Height - 1 do begin
     696    for ix := 0 to Width - 1 do begin
     697      trans := SrcPixel.Pixel^.B * 2; // green channel = transparency
     698      amp0 := SrcPixel.Pixel^.G * 2;
     699      amp1 := SrcPixel.Pixel^.R * 2;
     700      if trans <> $FF then begin
     701        Value := (DstPixel.Pixel^.B * trans + (Color2 shr 16 and $FF) * amp1 +
     702          (Color0 shr 16 and $FF) * amp0) div $FF;
     703        DstPixel.Pixel^.B := Min(Value, 255);
     704
     705        Value := (DstPixel.Pixel^.G * trans + (Color2 shr 8 and $FF) * amp1 +
     706          (Color0 shr 8 and $FF) * amp0) div $FF;
     707        DstPixel.Pixel^.G := Min(Value, 255);
     708
     709        Value := (DstPixel.Pixel^.R * trans + (Color2 and $FF) * amp1 +
     710          (Color0 and $FF) * amp0) div $FF;
     711        DstPixel.Pixel^.R := Min(Value, 255);
     712      end;
     713      SrcPixel.NextPixel;
     714      DstPixel.NextPixel;
     715    end;
     716    SrcPixel.NextLine;
     717    DstPixel.NextLine;
     718  end;
     719  Src.EndUpdate;
     720  Dst.EndUpdate;
    675721end;
    676722
Note: See TracChangeset for help on using the changeset viewer.