Changeset 539
- Timestamp:
- Apr 16, 2024, 11:43:51 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Integrated.lpi
r504 r539 418 418 <CustomOptions Value="-dDEBUG 419 419 -dDPI"/> 420 <OtherDefines Count="2">421 <Define0 Value="DEBUG"/>422 <Define1 Value="DPI"/>423 </OtherDefines>424 420 </Other> 425 421 </CompilerOptions> -
trunk/Packages/Common/Languages/PixelPointer.pot
r506 r539 4 4 #: pixelpointer.soutofrange 5 5 #, object-pascal-format 6 msgid "Pixel pointer out of range [X: %d . Y: %d]"6 msgid "Pixel pointer out of range [X: %d, Y: %d, Width: %d, Height: %d]" 7 7 msgstr "" 8 8 -
trunk/Packages/Common/PixelPointer.pas
r506 r539 34 34 function GetPixelB: Byte; inline; 35 35 function GetPixelG: Byte; inline; 36 function GetPixelPlane(Index: Byte): Byte; 36 function GetPixelPlane(Index: Byte): Byte; inline; 37 37 function GetPixelR: Byte; inline; 38 38 function GetPixelA: Byte; inline; 39 39 function GetPixelPlanes: TColor32Planes; 40 function GetPixelRGB: Cardinal; 40 function GetPixelRGB: Cardinal; inline; 41 41 procedure SetPixelARGB(Value: TColor32); inline; 42 42 procedure SetPixelB(Value: Byte); inline; 43 43 procedure SetPixelG(Value: Byte); inline; 44 procedure SetPixelPlane(Index: Byte; AValue: Byte); 44 procedure SetPixelPlane(Index: Byte; AValue: Byte); inline; 45 45 procedure SetPixelR(Value: Byte); inline; 46 46 procedure SetPixelA(Value: Byte); inline; 47 procedure SetPixelRGB(Value: Cardinal); 47 procedure SetPixelRGB(Value: Cardinal); inline; 48 48 public 49 49 Base: PPixel32; … … 63 63 procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base 64 64 procedure CheckRange; inline; // Check if current pixel position is not out of range 65 function PosValid: Boolean; 65 66 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; static; 66 67 property PixelARGB: TColor32 read GetPixelARGB write SetPixelARGB; … … 93 94 94 95 resourcestring 95 SOutOfRange = 'Pixel pointer out of range [X: %d . Y: %d]';96 SOutOfRange = 'Pixel pointer out of range [X: %d, Y: %d, Width: %d, Height: %d]'; 96 97 SWrongBitmapSize = 'Wrong bitmap size [width: %d, height: %d]'; 97 98 … … 105 106 procedure TPixel32.SetRGB(AValue: Cardinal); 106 107 begin 107 R := (AValue shr 16) and $ff; 108 G := (AValue shr 8) and $ff; 109 B := (AValue shr 0) and $ff; 108 ARGB := (ARGB and $ff000000) or (AValue and $ffffff); 110 109 end; 111 110 … … 159 158 X := X - Y * BytesPerLine; 160 159 X := Floor(X / BytesPerPixel); 161 raise Exception.Create(Format(SOutOfRange, [X, Y ]));160 raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height])); 162 161 end; 163 162 {$ENDIF} 163 end; 164 165 function TPixelPointer.PosValid: Boolean; 166 begin 167 Result := not ((PByte(Pixel) < PByte(Data)) or 168 (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine)); 164 169 end; 165 170 -
trunk/Packages/DpiControls/Dpi.Common.pas
r538 r539 66 66 XNative, YNative: Integer; 67 67 DstPixelWidth, DstPixelHeight: Integer; 68 NewX, NewY: Integer; 68 69 begin 69 70 if Frac(ScreenInfo.Dpi / 96) = 0 then 70 71 begin 71 72 // Use faster non-fractional scaling 72 Result := BitBlt(Dest.Canvas.Handle, X, Y, Width, Height, Src.Canvas.Handle, XSrc, YSrc, Rop); 73 Result := BitBlt(Dest.Canvas.Handle, X, Y, Width, Height, Src.Canvas.Handle, 74 XSrc, YSrc, Rop); 73 75 Exit; 74 76 end; … … 101 103 SrcPixel := TPixelPointer.Create(Src.NativeBitmap); 102 104 DstPixel := TPixelPointer.Create(Dest.NativeBitmap); 103 for YY := 0 to Height - 1 do begin 104 DstPixelHeight := ScaleToNative(Y + YY + 1) - ScaleToNative(Y + YY); 105 for DstPixelY := 0 to DstPixelHeight - 1 do begin 106 for XX := 0 to Width - 1 do begin 107 SrcPixel.SetXY(ScaleToNative(XSrc + XX), ScaleToNative(YSrc + YY)); 108 DstPixel.SetXY(ScaleToNative(X + XX), ScaleToNative(Y + YY) + DstPixelY); 109 DstPixelWidth := ScaleToNative(X + XX + 1) - ScaleToNative(X + XX); 110 for DstPixelX := 0 to DstPixelWidth - 1 do begin 111 {$IFDEF DEBUG} 112 if SrcPixel.PosValid and DstPixel.PosValid then 113 {$ENDIF} 114 if Rop = SRCCOPY then begin 115 DstPixel.PixelB := SrcPixel.PixelB; 116 DstPixel.PixelG := SrcPixel.PixelG; 117 DstPixel.PixelR := SrcPixel.PixelR; 118 end else 119 if Rop = SRCPAINT then begin 120 DstPixel.PixelB := SrcPixel.PixelB or DstPixel.PixelB; 121 DstPixel.PixelG := SrcPixel.PixelG or DstPixel.PixelG; 122 DstPixel.PixelR := SrcPixel.PixelR or DstPixel.PixelR; 123 end else 124 if Rop = SRCAND then begin 125 DstPixel.PixelB := SrcPixel.PixelB and DstPixel.PixelB; 126 DstPixel.PixelG := SrcPixel.PixelG and DstPixel.PixelG; 127 DstPixel.PixelR := SrcPixel.PixelR and DstPixel.PixelR; 128 end else 129 if Rop = DSTINVERT then begin 130 DstPixel.PixelB := not DstPixel.PixelB; 131 DstPixel.PixelG := not DstPixel.PixelG; 132 DstPixel.PixelR := not DstPixel.PixelR; 133 end else begin 134 raise Exception.Create(SUnsupportedPaintOperationType); 135 end; 136 DstPixel.NextPixel; 105 if Rop = SRCCOPY then begin 106 for YY := 0 to Height - 1 do begin 107 NewY := ScaleToNative(Y + YY); 108 DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY; 109 SrcPixel.SetXY(0, ScaleToNative(YSrc + YY)); 110 for DstPixelY := 0 to DstPixelHeight - 1 do begin 111 DstPixel.SetXY(0, NewY + DstPixelY); 112 for XX := 0 to Width - 1 do begin 113 SrcPixel.SetX(ScaleToNative(XSrc + XX)); 114 NewX := ScaleToNative(X + XX); 115 DstPixel.SetX(NewX); 116 DstPixelWidth := ScaleToNative(X + XX + 1) - NewX; 117 for DstPixelX := 0 to DstPixelWidth - 1 do begin 118 DstPixel.PixelRGB := SrcPixel.PixelARGB; 119 DstPixel.NextPixel; 120 end; 137 121 end; 138 122 end; 139 //DstPixel.NextLine; 140 end; 141 end; 123 end; 124 end else 125 if Rop = SRCPAINT then begin 126 for YY := 0 to Height - 1 do begin 127 NewY := ScaleToNative(Y + YY); 128 DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY; 129 SrcPixel.SetXY(0, ScaleToNative(YSrc + YY)); 130 for DstPixelY := 0 to DstPixelHeight - 1 do begin 131 DstPixel.SetXY(0, NewY + DstPixelY); 132 for XX := 0 to Width - 1 do begin 133 SrcPixel.SetX(ScaleToNative(XSrc + XX)); 134 NewX := ScaleToNative(X + XX); 135 DstPixel.SetX(NewX); 136 DstPixelWidth := ScaleToNative(X + XX + 1) - NewX; 137 for DstPixelX := 0 to DstPixelWidth - 1 do begin 138 DstPixel.PixelRGB := SrcPixel.PixelARGB or DstPixel.PixelARGB; 139 DstPixel.NextPixel; 140 end; 141 end; 142 end; 143 end; 144 end else 145 if Rop = SRCAND then begin 146 for YY := 0 to Height - 1 do begin 147 NewY := ScaleToNative(Y + YY); 148 DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY; 149 SrcPixel.SetXY(0, ScaleToNative(YSrc + YY)); 150 for DstPixelY := 0 to DstPixelHeight - 1 do begin 151 DstPixel.SetXY(0, NewY + DstPixelY); 152 for XX := 0 to Width - 1 do begin 153 SrcPixel.SetX(ScaleToNative(XSrc + XX)); 154 NewX := ScaleToNative(X + XX); 155 DstPixel.SetX(NewX); 156 DstPixelWidth := ScaleToNative(X + XX + 1) - NewX; 157 for DstPixelX := 0 to DstPixelWidth - 1 do begin 158 DstPixel.PixelRGB := SrcPixel.PixelARGB and DstPixel.PixelARGB; 159 DstPixel.NextPixel; 160 end; 161 end; 162 end; 163 end; 164 end else 165 if Rop = DSTINVERT then begin 166 for YY := 0 to Height - 1 do begin 167 NewY := ScaleToNative(Y + YY); 168 DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY; 169 SrcPixel.SetXY(0, ScaleToNative(YSrc + YY)); 170 for DstPixelY := 0 to DstPixelHeight - 1 do begin 171 DstPixel.SetXY(0, NewY + DstPixelY); 172 for XX := 0 to Width - 1 do begin 173 SrcPixel.SetX(ScaleToNative(XSrc + XX)); 174 NewX := ScaleToNative(X + XX); 175 DstPixel.SetX(NewX); 176 DstPixelWidth := ScaleToNative(X + XX + 1) - NewX; 177 for DstPixelX := 0 to DstPixelWidth - 1 do begin 178 DstPixel.PixelRGB := not DstPixel.PixelARGB; 179 DstPixel.NextPixel; 180 end; 181 end; 182 end; 183 end; 184 end else raise Exception.Create(SUnsupportedPaintOperationType); 142 185 Dest.EndUpdate; 143 186 Result := True; -
trunk/Packages/DpiControls/Dpi.PixelPointer.pas
r538 r539 34 34 function GetPixelB: Byte; inline; 35 35 function GetPixelG: Byte; inline; 36 function GetPixelPlane(Index: Byte): Byte; 36 function GetPixelPlane(Index: Byte): Byte; inline; 37 37 function GetPixelR: Byte; inline; 38 38 function GetPixelA: Byte; inline; 39 39 function GetPixelPlanes: TColor32Planes; 40 function GetPixelRGB: Cardinal; 40 function GetPixelRGB: Cardinal; inline; 41 41 procedure SetPixelARGB(Value: TColor32); inline; 42 42 procedure SetPixelB(Value: Byte); inline; 43 43 procedure SetPixelG(Value: Byte); inline; 44 procedure SetPixelPlane(Index: Byte; AValue: Byte); 44 procedure SetPixelPlane(Index: Byte; AValue: Byte); inline; 45 45 procedure SetPixelR(Value: Byte); inline; 46 46 procedure SetPixelA(Value: Byte); inline; 47 procedure SetPixelRGB(Value: Cardinal); 47 procedure SetPixelRGB(Value: Cardinal); inline; 48 48 public 49 49 Base: PPixel32; … … 63 63 procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base 64 64 procedure CheckRange; inline; // Check if current pixel position is not out of range 65 function PosValid: Boolean; 65 66 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; static; 66 67 property PixelARGB: TColor32 read GetPixelARGB write SetPixelARGB; … … 105 106 procedure TPixel32.SetRGB(AValue: Cardinal); 106 107 begin 107 R := (AValue shr 16) and $ff; 108 G := (AValue shr 8) and $ff; 109 B := (AValue shr 0) and $ff; 108 ARGB := (ARGB and $ff000000) or (AValue and $ffffff); 110 109 end; 111 110 … … 148 147 {$IFOPT R+} 149 148 var 150 B: Integer;151 149 X: Integer; 152 150 Y: Integer; … … 156 154 if (PByte(Pixel) < PByte(Data)) or 157 155 (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine) then begin 158 B:= PByte(Pixel) - PByte(Data);159 Y := Floor( B/ BytesPerLine);160 X := B- Y * BytesPerLine;156 X := PByte(Pixel) - PByte(Data); 157 Y := Floor(X / BytesPerLine); 158 X := X - Y * BytesPerLine; 161 159 X := Floor(X / BytesPerPixel); 162 160 raise Exception.Create(Format(SOutOfRange, [X, Y, Width, Height])); 163 161 end; 164 162 {$ENDIF} 163 end; 164 165 function TPixelPointer.PosValid: Boolean; 166 begin 167 Result := not ((PByte(Pixel) < PByte(Data)) or 168 (PByte(Pixel) >= PByte(Data) + Height * BytesPerLine)); 165 169 end; 166 170 -
trunk/Packages/DpiControls/NativePixelPointer.pas
r538 r539 34 34 function GetPixelB: Byte; inline; 35 35 function GetPixelG: Byte; inline; 36 function GetPixelPlane(Index: Byte): Byte; 36 function GetPixelPlane(Index: Byte): Byte; inline; 37 37 function GetPixelR: Byte; inline; 38 38 function GetPixelA: Byte; inline; 39 39 function GetPixelPlanes: TColor32Planes; 40 function GetPixelRGB: Cardinal; 40 function GetPixelRGB: Cardinal; inline; 41 41 procedure SetPixelARGB(Value: TColor32); inline; 42 42 procedure SetPixelB(Value: Byte); inline; 43 43 procedure SetPixelG(Value: Byte); inline; 44 procedure SetPixelPlane(Index: Byte; AValue: Byte); 44 procedure SetPixelPlane(Index: Byte; AValue: Byte); inline; 45 45 procedure SetPixelR(Value: Byte); inline; 46 46 procedure SetPixelA(Value: Byte); inline; 47 procedure SetPixelRGB(Value: Cardinal); 47 procedure SetPixelRGB(Value: Cardinal); inline; 48 48 public 49 49 Base: PPixel32; … … 106 106 procedure TPixel32.SetRGB(AValue: Cardinal); 107 107 begin 108 R := (AValue shr 16) and $ff; 109 G := (AValue shr 8) and $ff; 110 B := (AValue shr 0) and $ff; 108 ARGB := (ARGB and $ff000000) or (AValue and $ffffff); 111 109 end; 112 110
Note:
See TracChangeset
for help on using the changeset viewer.