- Timestamp:
- Sep 6, 2020, 12:31:43 PM (4 years ago)
- Location:
- tools/Image resize
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/Image resize/ImageResize.lpi
r276 r280 31 31 </Item1> 32 32 </RequiredPackages> 33 <Units Count=" 4">33 <Units Count="5"> 34 34 <Unit0> 35 35 <Filename Value="ImageResize.lpr"/> … … 52 52 <IsPartOfProject Value="True"/> 53 53 </Unit3> 54 <Unit4> 55 <Filename Value="UPixelPointer.pas"/> 56 <IsPartOfProject Value="True"/> 57 </Unit4> 54 58 </Units> 55 59 </ProjectOptions> … … 63 67 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 64 68 </SearchPaths> 69 <Parsing> 70 <SyntaxOptions> 71 <SyntaxMode Value="Delphi"/> 72 </SyntaxOptions> 73 </Parsing> 65 74 <Linking> 66 75 <Options> -
tools/Image resize/uformmain.pas
r276 r280 7 7 uses 8 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, 9 Math, LazFileUtils ;9 Math, LazFileUtils, UPixelPointer; 10 10 11 11 type … … 27 27 end; 28 28 29 TColor32 = type Cardinal;30 TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha);31 TPixel32 = packed record32 case Integer of33 0: (B, G, R, A: Byte);34 1: (ARGB: TColor32);35 2: (Planes: array[0..3] of Byte);36 3: (Components: array[TColor32Component] of Byte);37 end;38 PPixel32 = ^TPixel32;39 40 29 var 41 30 FormMain: TFormMain; … … 65 54 begin 66 55 NewSize := Point(144, 108); 67 ResizeImage('../../trunk/Graphics/Cities66x32.png', Point(66, 48), Point(8, 2), 56 //ResizeImage('../../trunk/Graphics/Cities66x32.png', Point(66, 48), Point(8, 2), 57 // 'Cities144x72.png', NewSize); 58 //ResizeImage('../../trunk/Graphics/Terrain66x32.png', Point(66, 48), Point(9, 21), 59 // 'Terrain144x72.png', NewSize); 60 { 61 ResizeImage('../../trunk/Graphics/Cities96x48.png', Point(96, 72), Point(8, 2), 68 62 'Cities144x72.png', NewSize); 69 ResizeImage('../../trunk/Graphics/Terrain66x32.png', Point(66, 48), Point(9, 21), 63 ResizeImage('../../trunk/Graphics/Terrain96x48.png', Point(96, 72), Point(9, 21), 64 'Terrain144x72.png', NewSize); 65 } ResizeImage('../../branches/AlphaChannel/Graphics/Cities96x48.png', Point(96, 72), Point(8, 2), 66 'Cities144x72.png', NewSize); 67 ResizeImage('../../branches/AlphaChannel/Graphics/Terrain96x48.png', Point(96, 72), Point(9, 21), 70 68 'Terrain144x72.png', NewSize); 71 69 end; … … 84 82 for I := 0 to Length(Files) - 1 do 85 83 UseAlpha('../../trunk/Graphics/' + Files[I], False); 84 UseAlpha('../../trunk/Help/AdvTree.png', False); 86 85 //UseAlpha('../../trunk/Graphics/Templates.png', True); 86 end; 87 88 procedure FillRectBitmap(Bitmap: TBitmap; Color: TColor32); 89 var 90 Ptr: TPixelPointer; 91 X, Y: Integer; 92 begin 93 Bitmap.BeginUpdate; 94 Ptr := PixelPointer(Bitmap); 95 for Y := 0 to Bitmap.Height - 1 do begin 96 for X := 0 to Bitmap.Width - 1 do begin 97 Ptr.Pixel^.ARGB := Color; 98 Ptr.NextPixel; 99 end; 100 Ptr.NextLine; 101 end; 102 Bitmap.EndUpdate; 87 103 end; 88 104 … … 176 192 XX, YY: Integer; 177 193 X, Y: Integer; 178 SrcPtr: P Integer;179 DestPtr: P Integer;194 SrcPtr: PCardinal; 195 DestPtr: PCardinal; 180 196 begin 181 197 ImageSrc := TImage.Create(nil); 182 198 ImageSrc.Picture.LoadFromFile(SourceName); 183 199 ImageDest := TImage.Create(nil); 200 ImageDest.Picture.Bitmap.Assign(ImageSrc.Picture.Bitmap); 184 201 ImageDest.Picture.Bitmap.SetSize((DestSize.X + 1) * Count.X + 1, 185 202 (DestSize.Y + 1) * Count.Y + 1); 186 203 //ShowMessage(IntToStr(ImageDest.Picture.Bitmap.Width) + ' ' + IntToStr(ImageDest.Width)); 204 FillRectBitmap(ImageDest.Picture.Bitmap, $ff757575); 205 187 206 ImageSrc.Picture.Bitmap.BeginUpdate(True); 188 207 ImageDest.Picture.Bitmap.BeginUpdate(True); 189 ImageDest.Picture.Bitmap.Canvas.Brush.Style := bsSolid;190 ImageDest.Picture.Bitmap.Canvas.Brush.Color := $757575;191 ImageDest.Picture.Bitmap.Canvas.FillRect(0, 0, ImageDest.Picture.Bitmap.Width, ImageDest.Picture.Bitmap.Height);208 //ImageDest.Picture.Bitmap.Canvas.Brush.Style := bsSolid; 209 //ImageDest.Picture.Bitmap.Canvas.Brush.Color := $757575; 210 //ImageDest.Picture.Bitmap.Canvas.FillRect(0, 0, ImageDest.Picture.Bitmap.Width, ImageDest.Picture.Bitmap.Height); 192 211 XX := 0; 193 212 YY := 0; 194 213 for YY := 0 to Count.Y - 1 do 195 for XX := 0 to Count.X - 1 do 196 begin 214 for XX := 0 to Count.X - 1 do begin 197 215 for Y := 0 to DestSize.Y - 1 do 198 216 for X := 0 to DestSize.X - 1 do begin
Note:
See TracChangeset
for help on using the changeset viewer.