Changeset 208 for trunk/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- May 8, 2020, 6:51:18 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/ScreenTools.pas
r206 r208 36 36 overload; 37 37 procedure MakeBlue(dst: TBitmap; x, y, Width, Height: Integer); 38 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h: integer);38 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height: Integer); 39 39 procedure 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); 41 procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height, 42 Color0, Color2: Integer); 43 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer); 42 44 function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer; 43 45 SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload; … … 555 557 end; 556 558 557 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h: Integer);559 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height: Integer); 558 560 // Src is template 559 561 // X channel = background amp (old Dst content), 128=original brightness … … 567 569 Assert(dst.PixelFormat = pf24bit); 568 570 if xDst < 0 then begin 569 w := w+ xDst;571 Width := Width + xDst; 570 572 xSrc := xSrc - xDst; 571 573 xDst := 0; 572 574 end; 573 575 if yDst < 0 then begin 574 h := h+ yDst;576 Height := Height + yDst; 575 577 ySrc := ySrc - yDst; 576 578 yDst := 0; 577 579 end; 578 if xDst + w> dst.Width then579 w:= dst.Width - xDst;580 if yDst + h> dst.Height then581 h:= dst.Height - yDst;582 if ( w < 0) or (h< 0) then580 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 583 585 exit; 584 586 … … 587 589 PixelDst := PixelPointer(Dst, xDst, yDst); 588 590 PixelSrc := PixelPointer(Src, xSrc, ySrc); 589 for Y := 0 to h- 1 do begin590 for X := 0 to w- 1 do begin591 for Y := 0 to Height - 1 do begin 592 for X := 0 to Width - 1 do begin 591 593 Brightness := PixelSrc.Pixel^.B; // One byte for 8-bit color 592 594 test := (PixelDst.Pixel^.R * Brightness) shr 7; … … 616 618 617 619 procedure ImageOp_BCC(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height, 618 Color1, Color2: integer);620 Color1, Color2: Integer); 619 621 // Src is template 620 622 // B channel = background amp (old Dst content), 128=original brightness … … 622 624 // R channel = Color2 amp, 128=original brightness 623 625 var 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; 626 629 begin 627 630 if xDst < 0 then begin … … 673 676 Src.EndUpdate; 674 677 dst.EndUpdate; 678 end; 679 680 procedure 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 686 var 687 ix, iy, amp0, amp1, trans, Value: integer; 688 SrcPixel: TPixelPointer; 689 DstPixel: TPixelPointer; 690 begin 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; 675 721 end; 676 722
Note:
See TracChangeset
for help on using the changeset viewer.