Changeset 245 for trunk/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- May 21, 2020, 7:58:42 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/ScreenTools.pas
r230 r245 42 42 procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height, 43 43 Color0, Color2: Integer); 44 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);44 procedure ImageOp_CCC(bmp: TBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer); 45 45 function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer; 46 46 SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload; … … 58 58 procedure FrameImage(ca: TCanvas; Src: TBitmap; 59 59 x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False); 60 procedure GlowFrame( dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor);60 procedure GlowFrame(Dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor); 61 61 procedure InitOrnament; 62 62 procedure InitCityMark(const T: TTexture); … … 93 93 procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Integer); 94 94 procedure DarkenImage(Bitmap: TBitmap; Change: Integer); 95 function ScaleToNative(Value: Integer): Integer; 96 function ScaleFromNative(Value: Integer): Integer; 95 97 96 98 const … … 364 366 Bitmap.BeginUpdate; 365 367 PixelPtr := PixelPointer(Bitmap); 366 for Y := 0 to Bitmap.Height- 1 do begin367 for X := 0 to Bitmap.Width- 1 do begin368 for Y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin 369 for X := 0 to ScaleToNative(Bitmap.Width) - 1 do begin 368 370 PixelPtr.Pixel^ := ApplyGammaToPixel(PixelPtr.Pixel^); 369 371 PixelPtr.NextPixel; … … 382 384 SrcPtr := PixelPointer(Src); 383 385 DstPtr := PixelPointer(Dst); 384 for Y := 0 to S rc.Height - 1do begin385 for X := 0 to S rc.Width - 1do begin386 for Y := 0 to ScaleToNative(Src.Height - 1) do begin 387 for X := 0 to ScaleToNative(Src.Width - 1) do begin 386 388 DstPtr.Pixel^.B := SrcPtr.Pixel^.B; 387 389 DstPtr.Pixel^.G := SrcPtr.Pixel^.B; … … 404 406 Path := Path + '.png'; 405 407 if ExtractFileExt(Path) = '.jpg' then begin 406 jtex := tjpegimage.Create;408 jtex := TJpegImage.Create; 407 409 try 408 410 jtex.LoadFromFile(Path); … … 506 508 DataPixel := PixelPointer(GrExt[nGrExt].Data); 507 509 MaskPixel := PixelPointer(GrExt[nGrExt].Mask); 508 for y := 0 to S ource.Height- 1 do begin509 for x := 0 to xmax- 1 do begin510 for y := 0 to ScaleToNative(Source.Height) - 1 do begin 511 for x := 0 to ScaleToNative(xmax) - 1 do begin 510 512 OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF; 511 513 if (OriginalColor = $FF00FF) or (OriginalColor = $7F007F) then … … 545 547 begin 546 548 Dst.BeginUpdate; 547 PixelPtr := PixelPointer(Dst, X, Y);548 for yy := 0 to Height- 1 do begin549 for xx := 0 to Width- 1 do begin549 PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y)); 550 for yy := 0 to ScaleToNative(Height) - 1 do begin 551 for xx := 0 to ScaleToNative(Width) - 1 do begin 550 552 PixelPtr.Pixel^.B := PixelPtr.Pixel^.B div 2; 551 553 PixelPtr.Pixel^.G := PixelPtr.Pixel^.G div 2; … … 565 567 begin 566 568 Dst.BeginUpdate; 567 PixelPtr := PixelPointer(Dst, X, Y);568 for YY := 0 to Height- 1 do begin569 for XX := 0 to Width- 1 do begin569 PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y)); 570 for YY := 0 to ScaleToNative(Height) - 1 do begin 571 for XX := 0 to ScaleToNative(Width) - 1 do begin 570 572 Gray := (Integer(PixelPtr.Pixel^.B) + Integer(PixelPtr.Pixel^.G) + 571 573 Integer(PixelPtr.Pixel^.R)) * 85 shr 8; … … 589 591 PixelDst: TPixelPointer; 590 592 begin 593 xDst := ScaleToNative(xDst); 594 yDst := ScaleToNative(yDst); 595 xSrc := ScaleToNative(xSrc); 596 ySrc := ScaleToNative(ySrc); 597 Width := ScaleToNative(Width); 598 Height := ScaleToNative(Height); 591 599 //Assert(Src.PixelFormat = pf8bit); 592 600 Assert(dst.PixelFormat = pf24bit); … … 601 609 yDst := 0; 602 610 end; 603 if xDst + Width > dst.Widththen604 Width := dst.Width- xDst;605 if yDst + Height > dst.Heightthen606 Height := dst.Height- yDst;611 if xDst + Width > ScaleToNative(dst.Width) then 612 Width := ScaleToNative(dst.Width) - xDst; 613 if yDst + Height > ScaleToNative(dst.Height) then 614 Height := ScaleToNative(dst.Height) - yDst; 607 615 if (Width < 0) or (Height < 0) then 608 616 exit; … … 651 659 DstPixel: TPixelPointer; 652 660 begin 661 xDst := ScaleToNative(xDst); 662 yDst := ScaleToNative(yDst); 663 xSrc := ScaleToNative(xSrc); 664 ySrc := ScaleToNative(ySrc); 665 Width := ScaleToNative(Width); 666 Height := ScaleToNative(Height); 653 667 if xDst < 0 then begin 654 668 Width := Width + xDst; … … 661 675 yDst := 0; 662 676 end; 663 if xDst + Width > dst.Widththen664 Width := dst.Width- xDst;665 if yDst + Height > dst.Heightthen666 Height := dst.Height- yDst;677 if xDst + Width > ScaleToNative(dst.Width) then 678 Width := ScaleToNative(dst.Width) - xDst; 679 if yDst + Height > ScaleToNative(dst.Height) then 680 Height := ScaleToNative(dst.Height) - yDst; 667 681 if (Width < 0) or (Height < 0) then 668 682 exit; … … 712 726 DstPixel: TPixelPointer; 713 727 begin 728 xDst := ScaleToNative(xDst); 729 yDst := ScaleToNative(yDst); 730 xSrc := ScaleToNative(xSrc); 731 ySrc := ScaleToNative(ySrc); 732 Width := ScaleToNative(Width); 733 Height := ScaleToNative(Height); 714 734 Src.BeginUpdate; 715 735 Dst.BeginUpdate; … … 744 764 end; 745 765 746 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);766 procedure ImageOp_CCC(bmp: TBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer); 747 767 // Bmp is template 748 768 // B channel = Color0 amp, 128=original brightness … … 753 773 PixelPtr: TPixelPointer; 754 774 begin 775 X := ScaleToNative(X); 776 Y := ScaleToNative(Y); 777 Width := ScaleToNative(Width); 778 Height := ScaleToNative(Height); 755 779 bmp.BeginUpdate; 756 780 assert(bmp.PixelFormat = pf24bit); 757 h := y + h;781 Height := y + Height; 758 782 PixelPtr := PixelPointer(Bmp, x, y); 759 while y < hdo begin760 for i := 0 to w- 1 do begin783 while y < Height do begin 784 for i := 0 to Width - 1 do begin 761 785 Red := ((PixelPtr.Pixel^.B * (Color0 and $0000FF) + PixelPtr.Pixel^.G * 762 786 (Color1 and $0000FF) + PixelPtr.Pixel^.R * (Color2 and $0000FF)) shr 8) and $ff; … … 905 929 end; 906 930 907 procedure GlowFrame( dst: TBitmap; x0, y0, Width, Height: Integer; cl: TColor);931 procedure GlowFrame(Dst: TBitmap; x0, y0, Width, Height: Integer; cl: TColor); 908 932 var 909 933 x, y, ch, r: Integer; 910 934 DstPtr: TPixelPointer; 911 begin 912 dst.BeginUpdate; 913 DstPtr := PixelPointer(dst, x0 - GlowRange + 1, y0 - GlowRange + 1); 914 for y := -GlowRange + 1 to Height - 1 + GlowRange - 1 do begin 915 for x := -GlowRange + 1 to Width - 1 + GlowRange - 1 do begin 935 DpiGlowRange: Integer; 936 begin 937 DpiGlowRange := ScaleToNative(GlowRange); 938 X0 := ScaleToNative(X0); 939 Y0 := ScaleToNative(Y0); 940 Width := ScaleToNative(Width); 941 Height := ScaleToNative(Height); 942 Dst.BeginUpdate; 943 DstPtr := PixelPointer(Dst, x0 - DpiGlowRange + 1, y0 - DpiGlowRange + 1); 944 for y := -DpiGlowRange + 1 to Height - 1 + DpiGlowRange - 1 do begin 945 for x := -DpiGlowRange + 1 to Width - 1 + DpiGlowRange - 1 do begin 916 946 if x < 0 then 917 947 if y < 0 then … … 938 968 if r = 0 then 939 969 r := 1; 940 if r < GlowRange then970 if r < DpiGlowRange then 941 971 for ch := 0 to 2 do 942 972 DstPtr.Pixel^.Planes[2 - ch] := 943 973 (DstPtr.Pixel^.Planes[2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) * 944 ( GlowRange - r)) div (GlowRange - 1);974 (DpiGlowRange - r)) div (DpiGlowRange - 1); 945 975 DstPtr.NextPixel; 946 976 end; 947 977 DstPtr.NextLine; 948 978 end; 949 dst.EndUpdate;979 Dst.EndUpdate; 950 980 end; 951 981 … … 1512 1542 DstPixel := PixelPointer(Dest); 1513 1543 SrcPixel := PixelPointer(Texture); 1514 for Y := 0 to Dest.Height- 1 do begin1515 for X := 0 to Dest.Width- 1 do begin1544 for Y := 0 to ScaleToNative(Dest.Height) - 1 do begin 1545 for X := 0 to ScaleToNative(Dest.Width) - 1 do begin 1516 1546 if (DstPixel.Pixel^.ARGB and $FFFFFF) = TransparentColor then begin 1517 1547 SrcPixel.SetXY(X mod TexWidth, Y mod TexHeight); … … 1534 1564 Bitmap.BeginUpdate; 1535 1565 PicturePixel := PixelPointer(Bitmap); 1536 for y := 0 to Bitmap.Height- 1 do begin1537 for x := 0 to Bitmap.Width- 1 do begin1566 for y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin 1567 for x := 0 to ScaleToNative(Bitmap.Width) - 1 do begin 1538 1568 PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - Change, 0); 1539 1569 PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - Change, 0); … … 1544 1574 end; 1545 1575 Bitmap.EndUpdate; 1576 end; 1577 1578 function ScaleToNative(Value: Integer): Integer; 1579 begin 1580 Result := Value; 1581 end; 1582 1583 function ScaleFromNative(Value: Integer): Integer; 1584 begin 1585 Result := Value; 1546 1586 end; 1547 1587
Note:
See TracChangeset
for help on using the changeset viewer.