Ignore:
Timestamp:
Sep 6, 2020, 12:31:43 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Upscaled from middle sized images.
  • Modified: Upscale transparent images with alpha color.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/Image resize/uformmain.pas

    r276 r280  
    77uses
    88  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
    9   Math, LazFileUtils;
     9  Math, LazFileUtils, UPixelPointer;
    1010
    1111type
     
    2727  end;
    2828
    29   TColor32 = type Cardinal;
    30   TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha);
    31   TPixel32 = packed record
    32     case Integer of
    33       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 
    4029var
    4130  FormMain: TFormMain;
     
    6554begin
    6655  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),
    6862    '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),
    7068    'Terrain144x72.png', NewSize);
    7169end;
     
    8482  for I := 0 to Length(Files) - 1 do
    8583    UseAlpha('../../trunk/Graphics/' + Files[I], False);
     84  UseAlpha('../../trunk/Help/AdvTree.png', False);
    8685  //UseAlpha('../../trunk/Graphics/Templates.png', True);
     86end;
     87
     88procedure FillRectBitmap(Bitmap: TBitmap; Color: TColor32);
     89var
     90  Ptr: TPixelPointer;
     91  X, Y: Integer;
     92begin
     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;
    87103end;
    88104
     
    176192  XX, YY: Integer;
    177193  X, Y: Integer;
    178   SrcPtr: PInteger;
    179   DestPtr: PInteger;
     194  SrcPtr: PCardinal;
     195  DestPtr: PCardinal;
    180196begin
    181197  ImageSrc := TImage.Create(nil);
    182198  ImageSrc.Picture.LoadFromFile(SourceName);
    183199  ImageDest := TImage.Create(nil);
     200  ImageDest.Picture.Bitmap.Assign(ImageSrc.Picture.Bitmap);
    184201  ImageDest.Picture.Bitmap.SetSize((DestSize.X + 1) * Count.X + 1,
    185202    (DestSize.Y + 1) * Count.Y + 1);
    186203  //ShowMessage(IntToStr(ImageDest.Picture.Bitmap.Width) + ' ' + IntToStr(ImageDest.Width));
     204  FillRectBitmap(ImageDest.Picture.Bitmap, $ff757575);
     205
    187206  ImageSrc.Picture.Bitmap.BeginUpdate(True);
    188207  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);
    192211  XX := 0;
    193212  YY := 0;
    194213  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
    197215      for Y := 0 to DestSize.Y - 1 do
    198216        for X := 0 to DestSize.X - 1 do begin
Note: See TracChangeset for help on using the changeset viewer.