Permalink
Browse files

Issue #448: Apply 192 new icons mainly from Icons8 gallery, with an O…

…penSource permission (talked to Eugenie from Icons8)
  • Loading branch information...
ansgarbecker committed Jan 26, 2019
1 parent 181940c commit aa0540921c7b85aff784c3652ffcf260afbbc599
@@ -1403,7 +1403,7 @@ object AboutBox: TAboutBox
Height = 25
Action = MainForm.actUpdateCheck
Anchors = [akLeft, akRight, akBottom]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
TabOrder = 0
end
object editDonated: TEdit
@@ -1426,7 +1426,7 @@ object AboutBox: TAboutBox
OnClick = btnDonatedOKClick
end
object popupLabels: TPopupMenu
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
Left = 32
Top = 144
object menuCopyLabel: TMenuItem
@@ -350,9 +350,6 @@ TAppSettings = class(TObject)
function GetUwpFullName: String;
function RunningAsUwp: Boolean;
function DpiScaleFactor(Form: TForm): Double;
procedure ScaleImageList(const ImgList: TImageList; ScaleFactor: Real);
procedure LoadPNGFromImageList(AImageList: TCustomImageList; AIndex: Integer; var ADestPNG: TPngImage);
procedure ResizePngImage(aPng: TPNGImage; NewWidth, NewHeight: Integer);
function GetThemeColor(Color: TColor): TColor;
function ThemeIsDark(ThemeName: String): Boolean;

@@ -1986,7 +1983,7 @@ procedure TDBObjectEditor.Init(Obj: TDBObject);
Continue;

popup := TPopupMenu.Create(Self);
popup.Images := MainForm.ImageListMain;
popup.Images := MainForm.VirtualImageListMain;

Item := TMenuItem.Create(popup);
Item.Action := MainForm.actCopy;
@@ -2982,181 +2979,6 @@ function DpiScaleFactor(Form: TForm): Double;
end;


procedure ScaleImageList(const ImgList: TImageList; ScaleFactor: Real);
var
ResizedImages: TImageList;
i: integer;
BitmapCopy: Graphics.TBitmap;
PngOrig: TPngImage;
ResizedWidth: Integer;
begin
// Upscale image list for high-dpi mode
if ScaleFactor = 1 then
Exit;

ResizedWidth := Round(imgList.Width * ScaleFactor);

// Create new list with resized icons
ResizedImages := TImageList.Create(ImgList.Owner);
ResizedImages.Width := ResizedWidth;
ResizedImages.Height := ResizedWidth;
ResizedImages.ColorDepth := ImgList.ColorDepth;
ResizedImages.DrawingStyle := ImgList.DrawingStyle;
ResizedImages.Clear;

for i:=0 to ImgList.Count-1 do begin
PngOrig := TPngImage.CreateBlank(COLOR_RGBALPHA, 8, ImgList.Width, ImgList.Height);
LoadPNGFromImageList(ImgList, i, PngOrig);
ResizePngImage(PngOrig, ResizedWidth, ResizedWidth);
BitmapCopy := Graphics.TBitmap.Create;
PngOrig.AssignTo(BitmapCopy);
BitmapCopy.AlphaFormat := afIgnored;
ImageList_Add(ResizedImages.Handle, BitmapCopy.Handle, 0);
end;

// Assign images to original instance
ImgList.Assign(ResizedImages);
end;


procedure LoadPNGFromImageList(AImageList: TCustomImageList; AIndex: Integer; var ADestPNG: TPngImage);
const
PixelsQuad = MaxInt div SizeOf(TRGBQuad) - 1;
type
TRGBAArray = Array [0..PixelsQuad - 1] of TRGBQuad;
PRGBAArray = ^TRGBAArray;
var
ContentBmp: Graphics.TBitmap;
RowInOut: PRGBAArray;
RowAlpha: PByteArray;
x: Integer;
y: Integer;
begin
// Extract PNG image with alpha transparency from an imagelist
// Code taken from https://stackoverflow.com/a/52811869/4110077

if not Assigned(AImageList) or (AIndex < 0)
or (AIndex > AImageList.Count - 1) or not Assigned(ADestPNG)
then
Exit;

ContentBmp := Graphics.TBitmap.Create;
try
ContentBmp.SetSize(ADestPNG.Width, ADestPNG.Height);
ContentBmp.PixelFormat := pf32bit;

// Allocate zero alpha-channel
for y:=0 to ContentBmp.Height - 1 do begin
RowInOut := ContentBmp.ScanLine[y];
for x:=0 to ContentBmp.Width - 1 do
RowInOut[x].rgbReserved := 0;
end;
ContentBmp.AlphaFormat := afDefined;

// Copy image
AImageList.Draw(ContentBmp.Canvas, 0, 0, AIndex, true);

// Now ContentBmp has premultiplied alpha value, but it will
// make bitmap too dark after converting it to PNG. Setting
// AlphaFormat property to afIgnored helps to unpremultiply
// alpha value of each pixel in bitmap.
ContentBmp.AlphaFormat := afIgnored;

// Copy graphical data and alpha-channel values
ADestPNG.Assign(ContentBmp);
ADestPNG.CreateAlpha;
for y:=0 to ContentBmp.Height - 1 do begin
RowInOut := ContentBmp.ScanLine[y];
RowAlpha := ADestPNG.AlphaScanline[y];
for x:=0 to ContentBmp.Width - 1 do
RowAlpha[x] := RowInOut[x].rgbReserved;
end;
finally
ContentBmp.Free;
end;
end;


procedure ResizePngImage(aPng: TPNGImage; NewWidth, NewHeight: Integer);
var
xscale, yscale: Single;
sfrom_y, sfrom_x: Single;
ifrom_y, ifrom_x: Integer;
to_y, to_x: Integer;
weight_x, weight_y: array[0..1] of Single;
weight: Single;
new_red, new_green: Integer;
new_blue, new_alpha: Integer;
new_colortype: Integer;
total_red, total_green: Single;
total_blue, total_alpha: Single;
IsAlpha: Boolean;
ix, iy: Integer;
bTmp: TPNGImage;
sli, slo: pRGBLine;
ali, alo: PByteArray;
begin
// Code taken from PNGDelphi component snippets, published by Gustavo Daud in 2006
// on SourceForge, now downloadable on https://cc.embarcadero.com/Item/25631 .
// Slightly but carefully modified for readability.
if not (aPng.Header.ColorType in [COLOR_RGBALPHA, COLOR_RGB]) then
Raise Exception.Create('Only COLOR_RGBALPHA and COLOR_RGB formats are supported');
IsAlpha := aPng.Header.ColorType in [COLOR_RGBALPHA];
if IsAlpha then
new_colortype := COLOR_RGBALPHA
else
new_colortype := COLOR_RGB;
bTmp := TPNGImage.CreateBlank(new_colortype, 8, NewWidth, NewHeight);
xscale := bTmp.Width / (aPng.Width-1);
yscale := bTmp.Height / (aPng.Height-1);
for to_y:=0 to bTmp.Height-1 do begin
sfrom_y := to_y / yscale;
ifrom_y := Trunc(sfrom_y);
weight_y[1] := sfrom_y - ifrom_y;
weight_y[0] := 1 - weight_y[1];
for to_x := 0 to bTmp.Width-1 do begin
sfrom_x := to_x / xscale;
ifrom_x := Trunc(sfrom_x);
weight_x[1] := sfrom_x - ifrom_x;
weight_x[0] := 1 - weight_x[1];

total_red := 0.0;
total_green := 0.0;
total_blue := 0.0;
total_alpha := 0.0;
for ix := 0 to 1 do begin
for iy := 0 to 1 do begin
sli := aPng.Scanline[ifrom_y + iy];
if IsAlpha then
ali := aPng.AlphaScanline[ifrom_y + iy];
new_red := sli[ifrom_x + ix].rgbtRed;
new_green := sli[ifrom_x + ix].rgbtGreen;
new_blue := sli[ifrom_x + ix].rgbtBlue;
if IsAlpha then
new_alpha := ali[ifrom_x + ix];
weight := weight_x[ix] * weight_y[iy];
total_red := total_red + new_red * weight;
total_green := total_green + new_green * weight;
total_blue := total_blue + new_blue * weight;
if IsAlpha then
total_alpha := total_alpha + new_alpha * weight;
end;
end;
slo := bTmp.ScanLine[to_y];
if IsAlpha then
alo := bTmp.AlphaScanLine[to_y];
slo[to_x].rgbtRed := Round(total_red);
slo[to_x].rgbtGreen := Round(total_green);
slo[to_x].rgbtBlue := Round(total_blue);
if isAlpha then
alo[to_x] := Round(total_alpha);
end;
end;
aPng.Assign(bTmp);
bTmp.Free;
end;


function GetThemeColor(Color: TColor): TColor;
begin
// Not required with vcl-style-utils:
@@ -52,7 +52,7 @@ object frmBinEditor: TfrmBinEditor
Align = alNone
Anchors = [akLeft, akBottom]
Caption = 'tlbStandard'
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
ParentShowHint = False
ShowHint = True
TabOrder = 1
@@ -60,7 +60,7 @@ object frmPasswordChange: TfrmPasswordChange
Width = 302
Height = 21
Anchors = [akLeft, akRight, akBottom]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.DropDownMenu = popupPassword
RightButton.ImageIndex = 75
RightButton.Visible = True
@@ -76,7 +76,7 @@ object frmPasswordChange: TfrmPasswordChange
Width = 302
Height = 21
Anchors = [akLeft, akRight, akBottom]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
PasswordChar = '*'
TabOrder = 1
TextHint = 'Retype password'
@@ -114,7 +114,7 @@ object frmPasswordChange: TfrmPasswordChange
Anchors = [akRight, akBottom]
Caption = 'Copy'
ImageIndex = 3
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
TabOrder = 4
OnClick = btnCopyToClipboardClick
end
@@ -79,7 +79,7 @@ object ColumnSelectionForm: TColumnSelectionForm
Width = 113
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
LeftButton.ImageIndex = 146
LeftButton.Visible = True
RightButton.ImageIndex = 26
@@ -86,7 +86,7 @@ object connform: Tconnform
Header.PopupMenu = MainForm.popupListHeader
Header.SortColumn = 0
HintMode = hmTooltip
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
IncrementalSearch = isAll
PopupMenu = popupSessions
TabOrder = 0
@@ -178,7 +178,7 @@ object connform: Tconnform
Margins.Bottom = 40
ActivePage = tabStart
Align = alClient
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
TabOrder = 7
object tabStart: TTabSheet
Caption = 'Start'
@@ -391,7 +391,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 75
RightButton.Visible = True
TabOrder = 9
@@ -521,7 +521,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51
RightButton.Visible = True
TabOrder = 0
@@ -558,7 +558,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51
RightButton.Visible = True
TabOrder = 7
@@ -665,7 +665,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51
RightButton.Visible = True
TabOrder = 1
@@ -680,7 +680,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51
RightButton.Visible = True
TabOrder = 2
@@ -695,7 +695,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51
RightButton.Visible = True
TabOrder = 3
@@ -733,7 +733,7 @@ object connform: Tconnform
Width = 294
Height = 21
Anchors = [akLeft, akTop, akRight]
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51
RightButton.Visible = True
TabOrder = 5
@@ -878,7 +878,7 @@ object connform: Tconnform
OnClick = btnMoreClick
end
object popupSessions: TPopupMenu
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
Left = 23
Top = 83
object menuRename: TMenuItem
@@ -930,7 +930,7 @@ object connform: Tconnform
Top = 35
end
object popupNew: TPopupMenu
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
Left = 109
Top = 82
object menuNewSessionInRoot: TMenuItem
@@ -955,7 +955,7 @@ object connform: Tconnform
end
end
object popupMore: TPopupMenu
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
Left = 24
Top = 144
object Preferences1: TMenuItem
@@ -89,7 +89,7 @@ object CopyTableForm: TCopyTableForm
Anchors = [akLeft, akTop, akRight, akBottom]
Header.AutoSizeIndex = 0
Header.MainColumn = -1
Images = MainForm.ImageListMain
Images = MainForm.VirtualImageListMain
TabOrder = 2
TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScroll, toAutoScrollOnExpand, toAutoTristateTracking, toAutoDeleteMovedNodes, toAutoChangeScale]
TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]
Oops, something went wrong.

0 comments on commit aa05409

Please sign in to comment.