Changeset 487
- Timestamp:
- Dec 8, 2023, 11:39:45 PM (12 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Select.pas
r486 r487 275 275 begin // city size 276 276 Brush.Color := $000000; 277 FillRect( rect(X - 4 - 11, Y + 1, X - 4 + 13, Y + 21));277 FillRect(Rect(X - 4 - 11, Y + 1, X - 4 + 13, Y + 21)); 278 278 Brush.Color := $FFFFFF; 279 FillRect( rect(X - 4 - 12, Y, X - 4 + 12, Y + 20));279 FillRect(Rect(X - 4 - 12, Y, X - 4 + 12, Y + 20)); 280 280 Brush.Style := TBrushStyle.bsClear; 281 281 Font.Color := $000000; … … 286 286 if Kind = kCityEvents then 287 287 begin 288 first := -1;288 First := -1; 289 289 for J := 0 to nCityEventPriority - 1 do 290 290 if (Flags and CityRepMask and CityEventPriority[J] <> 0) then 291 291 begin 292 first := J;292 First := J; 293 293 Break; 294 294 end; 295 if first >= 0 then295 if First >= 0 then 296 296 begin 297 297 I := 0; 298 298 Test := 1; 299 while Test < CityEventPriority[ first] do299 while Test < CityEventPriority[First] do 300 300 begin 301 301 Inc(I); … … 303 303 end; 304 304 S := CityEventName(I); 305 { if CityEventPriority[ first]=chNoGrowthWarning then306 if Built[imAqueduct] =0 then307 S :=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])308 else begin S :=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); I:=17 end; }305 { if CityEventPriority[First] = chNoGrowthWarning then 306 if Built[imAqueduct] = 0 then 307 S := Format(S, [Phrases.Lookup('IMPROVEMENTS', imAqueduct)]) 308 else begin S := Format(S, [Phrases.Lookup('IMPROVEMENTS', imSewer)]); I := 17 end; } 309 309 ReplaceText(X + (CityNameSpace + 4 + 40 + 18 + 8), Y, TextColor, S); 310 310 if NonText then … … 313 313 y0 + 1, 18, 18, 1 + I mod 3 * 19, 1 + I div 3 * 19); 314 314 X := InnerWidth - 26; 315 for J := nCityEventPriority - 1 downto first + 1 do315 for J := nCityEventPriority - 1 downto First + 1 do 316 316 if (Flags and CityRepMask and CityEventPriority[J] <> 0) then 317 317 begin -
trunk/MiniMap.pas
r479 r487 283 283 Bitmap.BeginUpdate; 284 284 MiniPixel := TPixelPointer.Create(Bitmap); 285 PrevMiniPixel := TPixelPointer.Create(Bitmap , 0, -1);285 PrevMiniPixel := TPixelPointer.Create(Bitmap); 286 286 287 287 xx := ScaleToNative(Size.X); … … 350 350 end; 351 351 MiniPixel.NextLine; 352 PrevMiniPixel.NextLine;352 if y > 0 then PrevMiniPixel.NextLine; 353 353 end; 354 354 Bitmap.EndUpdate; -
trunk/Packages/Common/PixelPointer.pas
r456 r487 35 35 BytesPerPixel: Integer; 36 36 BytesPerLine: Integer; 37 Data: PPixel32; 38 Width: Integer; 39 Height: Integer; 37 40 procedure NextLine; inline; // Move pointer to start of next line 38 41 procedure PreviousLine; inline; // Move pointer to start of previous line … … 41 44 procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base 42 45 procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base 43 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; inline; static; 46 procedure CheckRange; inline; // Check if current pixel position is not out of range 47 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; static; 44 48 end; 45 49 PPixelPointer = ^TPixelPointer; … … 63 67 implementation 64 68 69 resourcestring 70 SOutOfRange = 'Pixel pointer out of range'; 71 SWrongBitmapSize = 'Wrong bitmap size [width: %d, height: %d]'; 72 65 73 { TPixel32 } 66 74 … … 110 118 begin 111 119 Pixel := Pointer(Line) + X * BytesPerPixel; 120 end; 121 122 procedure TPixelPointer.CheckRange; 123 begin 124 {$IFOPT R+} 125 if (PByte(Pixel) < PByte(Data)) or 126 (PByte(Pixel) >= PByte(Data) + (Width + Height * BytesPerLine) * BytesPerPixel) then 127 raise Exception.Create(SOutOfRange); 128 {$ENDIF} 112 129 end; 113 130 … … 298 315 BaseY: Integer): TPixelPointer; 299 316 begin 317 Result.Width := Bitmap.Width; 318 Result.Height := Bitmap.Height; 319 if (Result.Width < 0) or (Result.Height < 0) then 320 raise Exception.Create(Format(SWrongBitmapSize, [Result.Width, Result.Height])); 300 321 Result.BytesPerLine := Bitmap.RawImage.Description.BytesPerLine; 301 322 Result.BytesPerPixel := Bitmap.RawImage.Description.BitsPerPixel shr 3; 323 Result.Data := PPixel32(Bitmap.RawImage.Data); 302 324 Result.Base := PPixel32(Bitmap.RawImage.Data + BaseX * Result.BytesPerPixel + 303 325 BaseY * Result.BytesPerLine); -
trunk/Packages/DpiControls/Dpi.Graphics.pas
r477 r487 270 270 procedure ScreenChanged; override; 271 271 public 272 procedure Assign(Source: TPersistent); override; 272 273 procedure SetSize(AWidth, AHeight: Integer); override; 273 274 end; … … 293 294 constructor Create; override; 294 295 destructor Destroy; override; 295 procedure Assign(Source: TPersistent); override;296 296 property ScanLine[Row: Integer]: Pointer read GetScanLine; 297 297 published … … 418 418 end; 419 419 420 procedure TCustomBitmap.Assign(Source: TPersistent); 421 begin 422 if Source is TCustomBitmap then begin 423 GetNativeCustomBitmap.Assign(TCustomBitmap(Source).GetNativeCustomBitmap); 424 FWidth := TCustomBitmap(Source).FWidth; 425 FHeight := TCustomBitmap(Source).FHeight 426 end else inherited; 427 end; 428 420 429 procedure TCustomBitmap.SetSize(AWidth, AHeight: Integer); 421 430 begin … … 691 700 //Exit; 692 701 Dst.BeginUpdate; 693 SrcPtr := PixelPointer(Src, 0, 0);694 DstPtr := PixelPointer(Dst, 0, 0);702 SrcPtr := TPixelPointer.Create(Src, 0, 0); 703 DstPtr := TPixelPointer.Create(Dst, 0, 0); 695 704 {for yy := 0 to Dst.Height - 1 do begin 696 705 for xx := 0 to Dst.Width - 1 do begin … … 841 850 end; 842 851 843 procedure TBitmap.Assign(Source: TPersistent);844 begin845 if Source is TBitmap then begin846 GetNativeBitmap.Assign((Source as TBitmap).GetNativeBitmap);847 end else inherited;848 end;849 850 852 { TPen } 851 853 -
trunk/Packages/DpiControls/Dpi.PixelPointer.pas
r468 r487 4 4 5 5 uses 6 Classes, SysUtils, Dpi.Graphics ;6 Classes, SysUtils, Dpi.Graphics, Dpi.Common; 7 7 8 8 type … … 35 35 BytesPerPixel: Integer; 36 36 BytesPerLine: Integer; 37 Data: PPixel32; 38 Width: Integer; 39 Height: Integer; 37 40 procedure NextLine; inline; // Move pointer to start of next line 38 41 procedure PreviousLine; inline; // Move pointer to start of previous line … … 41 44 procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base 42 45 procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base 43 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; inline; static; 46 procedure CheckRange; inline; // Check if current pixel position is not out of range 47 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; static; 44 48 end; 45 49 PPixelPointer = ^TPixelPointer; … … 63 67 implementation 64 68 69 resourcestring 70 SOutOfRange = 'Pixel pointer out of range'; 71 SWrongBitmapSize = 'Wrong bitmap size [width: %d, height: %d]'; 72 65 73 { TPixel32 } 66 74 … … 83 91 Line := Pointer(Line) + BytesPerLine; 84 92 Pixel := Line; 93 CheckRange; 85 94 end; 86 95 … … 89 98 Line := Pointer(Line) - BytesPerLine; 90 99 Pixel := Line; 100 CheckRange; 91 101 end; 92 102 … … 94 104 begin 95 105 Pixel := Pointer(Pixel) + BytesPerPixel; 106 CheckRange; 96 107 end; 97 108 … … 99 110 begin 100 111 Pixel := Pointer(Pixel) - BytesPerPixel; 112 CheckRange; 101 113 end; 102 114 … … 110 122 begin 111 123 Pixel := Pointer(Line) + X * BytesPerPixel; 124 CheckRange; 125 end; 126 127 procedure TPixelPointer.CheckRange; 128 begin 129 {$IFOPT R+} 130 if (PByte(Pixel) < PByte(Data)) or 131 (PByte(Pixel) >= PByte(Data) + (Width + Height * BytesPerLine) * BytesPerPixel) then 132 raise Exception.Create(SOutOfRange); 133 {$ENDIF} 112 134 end; 113 135 … … 298 320 BaseY: Integer): TPixelPointer; 299 321 begin 322 Result.Width := ScaleToNative(Bitmap.Width); 323 Result.Height := ScaleToNative(Bitmap.Height); 324 if (Result.Width < 0) or (Result.Height < 0) then 325 raise Exception.Create(Format(SWrongBitmapSize, [Result.Width, Result.Height])); 300 326 Result.BytesPerLine := Bitmap.RawImage.Description.BytesPerLine; 301 327 Result.BytesPerPixel := Bitmap.RawImage.Description.BitsPerPixel shr 3; 328 Result.Data := PPixel32(Bitmap.RawImage.Data); 302 329 Result.Base := PPixel32(Bitmap.RawImage.Data + BaseX * Result.BytesPerPixel + 303 330 BaseY * Result.BytesPerLine); -
trunk/Packages/DpiControls/NativePixelPointer.pas
r468 r487 32 32 BytesPerPixel: Integer; 33 33 BytesPerLine: Integer; 34 Data: PPixel32; 35 Width: Integer; 36 Height: Integer; 34 37 procedure NextLine; inline; // Move pointer to start of next line 35 38 procedure PreviousLine; inline; // Move pointer to start of previous line … … 38 41 procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base 39 42 procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base 43 procedure CheckRange; inline; // Check if current pixel position is not out of range 44 class function Create(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; static; 40 45 end; 41 46 PPixelPointer = ^TPixelPointer; 42 47 43 function PixelPointer(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; inline;44 48 function Color32ToColor(Color: TColor32): TColor; 45 49 function ColorToColor32(Color: TColor): TColor32; … … 48 52 implementation 49 53 50 { TPixel32 } 54 resourcestring 55 SOutOfRange = 'Pixel pointer out of range'; 56 SWrongBitmapSize = 'Wrong bitmap size [width: %d, height: %d]'; 57 58 { TPixel32 } 51 59 52 60 procedure TPixel32.SetRGB(Color: TColor32); … … 97 105 end; 98 106 99 function PixelPointer(Bitmap: TRasterImage; BaseX: Integer; 107 procedure TPixelPointer.CheckRange; 108 begin 109 {$IFOPT R+} 110 if (PByte(Pixel) < PByte(Data)) or 111 (PByte(Pixel) >= PByte(Data) + (Width + Height * BytesPerLine) * BytesPerPixel) then 112 raise Exception.Create(SOutOfRange); 113 {$ENDIF} 114 end; 115 116 class function TPixelPointer.Create(Bitmap: TRasterImage; BaseX: Integer; 100 117 BaseY: Integer): TPixelPointer; 101 118 begin 119 Result.Width := Bitmap.Width; 120 Result.Height := Bitmap.Height; 121 if (Result.Width < 0) or (Result.Height < 0) then 122 raise Exception.Create(Format(SWrongBitmapSize, [Result.Width, Result.Height])); 102 123 Result.BytesPerLine := Bitmap.RawImage.Description.BytesPerLine; 103 124 Result.BytesPerPixel := Bitmap.RawImage.Description.BitsPerPixel shr 3; 125 Result.Data := PPixel32(Bitmap.RawImage.Data); 104 126 Result.Base := PPixel32(Bitmap.RawImage.Data + BaseX * Result.BytesPerPixel + 105 127 BaseY * Result.BytesPerLine);
Note:
See TracChangeset
for help on using the changeset viewer.