Skip to content

Commit

Permalink
Replace gif with png
Browse files Browse the repository at this point in the history
  • Loading branch information
drapid committed May 19, 2020
1 parent 7b3b895 commit 4d719ea
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 3,353 deletions.
3,178 changes: 26 additions & 3,152 deletions HFS302_rus.utflng

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions RnQBuiltTime.inc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{ 18.05.2020 16:03:28 }
BuiltTime = 43969.6690770255;
{ 19.05.2020 10:57:57 }
BuiltTime = 43970.456914838;
Binary file modified data.res
Binary file not shown.
1 change: 0 additions & 1 deletion developer notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ Icons are generated at http://fontello.com/ . Use fontello.json for further modi

=== LIBS USED
ICS v8.58 by François PIETTE http://www.overbyte.be
GIFimage v2.2r5 by Anders Melander http://www.tolderlund.eu/delphi/
TRegExpr v0.952 by Andrey V. Sorokin http://www.regexpstudio.com/TRegExpr/TRegExpr.html
22 changes: 19 additions & 3 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,11 @@ function Tmainfrm.sendPic(cd:TconnData; idx:integer=-1):boolean;
exit;
}
cd.conn.reply.mode:=HRM_REPLY;
{$IFDEF HFS_GIF_IMAGES}
cd.conn.reply.contentType:='image/gif';
{$ELSE ~HFS_GIF_IMAGES}
cd.conn.reply.contentType:='image/png';
{$ENDIF HFS_GIF_IMAGES}
cd.conn.reply.bodyMode := RBM_RAW;
cd.downloadingWhat:=DW_ICON;
cd.lastFN:=copy(url,2,1000);
Expand Down Expand Up @@ -6355,6 +6359,7 @@ procedure Tmainfrm.updateSbar();
MEMORY = 'Mem';
CUSTOMIZED = 'Customized template';
ITEMS = 'VFS: %d items';
ITEMS_NS = 'VFS: %d items - not saved';
var
tempText: string;
begin
Expand All @@ -6373,8 +6378,7 @@ procedure Tmainfrm.updateSbar();
smartSize(outTotalOfs+srv.bytesSent)]) );
sbarIdxs.totalIn:=addPanel( format(TOT_IN,[
smartSize(inTotalOfs+srv.bytesReceived)]) );
sbarIdxs.notSaved:=addPanel( format(ITEMS,[filesBox.items.count-1])
+if_(VFSmodified,' - not saved') );
sbarIdxs.notSaved:=addPanel( format(if_(VFSmodified, ITEMS_NS, ITEMS),[filesBox.items.count-1]));
if not vFsmodified then sbarIdxs.notSaved:=-1;
end;
checkDiskSpace();
Expand Down Expand Up @@ -7536,7 +7540,11 @@ procedure TmainFrm.refreshConn(conn:TconnData);
FK_ACCOUNTS = 12;
FK_FILESFILTER = 13;
FK_FOLDERSFILTER = 14;
{$IFDEF HFS_GIF_IMAGES}
FK_ICON_GIF = 15;
{$ELSE ~HFS_GIF_IMAGES}
FK_ICON_PNG = 115;
{$ENDIF HFS_GIF_IMAGES}
FK_REALM = 16;
FK_UPLOADACCOUNTS = 17;
FK_DEFAULTMASK = 18;
Expand Down Expand Up @@ -7609,7 +7617,11 @@ function Tmainfrm.getVFS(node:Ttreenode=NIL): RawByteString;
result:=TLV(FK_NODE, commonFields
+TLVS_NOT_EMPTY(FK_NAME, f.name)
+TLV(FK_ADDEDTIME, str_(f.atime))
{$IFDEF HFS_GIF_IMAGES}
+TLV_NOT_EMPTY(FK_ICON_GIF, pic2str(f.icon))
{$ELSE ~HFS_GIF_IMAGES}
+TLV_NOT_EMPTY(FK_ICON_PNG, pic2str(f.icon))
{$ENDIF HFS_GIF_IMAGES}
+s
+result // subnodes
);
Expand Down Expand Up @@ -7759,7 +7771,11 @@ procedure Tmainfrm.setVFS2(vfs: RawByteString; node:Ttreenode=NIL);
FK_DIFF_TPL: f.diffTpl := UnUTF(data2);
FK_DONTCOUNTASDOWNLOADMASK: f.dontCountAsDownloadMask := UnUTF(data2);
FK_DONTCOUNTASDOWNLOAD: if boolean(data2[1]) then include(f.flags, FA_DONT_COUNT_AS_DL); // legacy, now moved into flags
{$IFDEF HFS_GIF_IMAGES}
FK_ICON_GIF: if data2 > '' then f.setupImage(mainfrm.useSystemIconsChk.checked, str2pic(data2));
{$ELSE ~HFS_GIF_IMAGES}
FK_ICON_PNG: if data2 > '' then f.setupImage(mainfrm.useSystemIconsChk.checked, str2pic(data2));
{$ENDIF HFS_GIF_IMAGES}
FK_AUTOUPDATED_FILES: parseAutoupdatedFiles(UnUTF(data2));
FK_HFS_BUILD: loadingVFS.build:= UnUTF(data2);
FK_HEAD, FK_HFS_VER: ; // recognize these fields, but do nothing
Expand Down Expand Up @@ -10276,7 +10292,7 @@ function Tmainfrm.finalInit():boolean;
exit;
end;

LoadSomeLanguage('HFS');
LoadSomeLanguage('HFS', exePath);
translateWindows;
show();
strToConnColumns(serializedConnColumns);
Expand Down
1 change: 0 additions & 1 deletion res/data.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
1 24 "WindowsXP.manifest"
defaultTpl TEXT default.tpl
copyright TEXT copyright.txt
dmBrowserTpl TEXT dmBrowser.tpl
invertban TEXT invertban.txt
filelistTpl TEXT filelist.tpl
Expand Down
Binary file added res/shell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
366 changes: 174 additions & 192 deletions shellExtDlg.dfm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion shellExtDlg.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, utilLib, Vcl.Imaging.GIFImg;
Dialogs, ExtCtrls, StdCtrls, utilLib, Vcl.Imaging.pngimage;

type
TshellExtFrm = class(TForm)
Expand Down
99 changes: 98 additions & 1 deletion utillib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ interface
types, windows, graphics, dialogs, registry, classes, dateUtils,
comCtrls, shlobj, shellapi, activex, comobj, forms, stdctrls, controls, psAPI,
menus, math, iniFiles, richedit, sysutils, strutils,
OverbyteIcsWSocket, OverbyteIcshttpProt, gifimg,
// Vcl.Imaging.gifimg,
Vcl.Imaging.pngImage,
OverbyteIcsWSocket, OverbyteIcshttpProt,
regexpr,
longinputDlg,
main, hslib,
Expand Down Expand Up @@ -58,8 +60,13 @@ procedure fixFontFor(frm:Tform);
function hostFromURL(s:string):string;
function hostToIP(name: string):string;
function allocatedMemory():int64;
{$IFDEF HFS_GIF_IMAGES}
function stringToGif(s: RawByteString; gif:TgifImage=NIL):TgifImage;
function gif2str(gif:TgifImage): RawByteString;
{$ELSE ~HFS_GIF_IMAGES}
function stringToPNG(s: RawByteString; png: TpngImage=NIL):TpngImage;
function png2str(png:TPngImage): RawByteString;
{$ENDIF HFS_GIF_IMAGES}
function bmp2str(bmp:Tbitmap): RawByteString;
function pic2str(idx:integer): RawByteString;
function str2pic(s: RawByteString):integer;
Expand Down Expand Up @@ -3137,6 +3144,7 @@ function deltree(path:string):boolean;
end;
end; // deltree

{$IFDEF HFS_GIF_IMAGES}
function stringToGif(s: RawByteString; gif: TgifImage=NIL):TgifImage;
var
ss: TAnsiStringStream;
Expand Down Expand Up @@ -3216,6 +3224,95 @@ function str2pic(s: RawByteString):integer;
gif.free
end;
end; // str2pic
{$ELSE ~HFS_GIF_IMAGES}
function stringToPNG(s: RawByteString; png: TpngImage=NIL):TpngImage;
var
ss: TAnsiStringStream;
begin
ss := TAnsiStringStream.create(s);
try
if png = NIL then
png:=TPNGImage.Create();
png.loadFromStream(ss);
result:=png;
finally ss.free end;
end; // stringToGif

function png2str(png:TpngImage): RawByteString;
var
stream: Tbytesstream;
begin
stream:=Tbytesstream.create();
png.SaveToStream(stream);
setLength(result, stream.size);
move(stream.bytes[0], result[1], stream.size);
stream.free;
end; // gif2str

function bmp2str(bmp:Tbitmap): RawByteString;
var
png: TPNGImage;
begin
png:=TPNGImage.Create();
try
// png.ColorReduction:=rmQuantize;
png.Assign(bmp);
result:=png2str(png);
finally png.free;
end;
end; // bmp2str

function pic2str(idx:integer): RawByteString;
var
ico: Ticon;
bmp: TBitmap;
png: TpngImage;
begin
result:='';
if idx < 0 then exit;
idx:=idx_ico2img(idx);
if length(imagescache) <= idx then
setlength(imagescache, idx+1);
result:=imagescache[idx];
if result > '' then exit;

ico:=Ticon.Create;
png:=TPNGImage.Create;
bmp := TBitmap.Create;
try
mainfrm.images.getIcon(idx, ico);
ico.AssignTo(bmp);
png.Assign(bmp);
result:=png2str(png);
imagescache[idx]:=result;
finally
bmp.Free;
png.Free;
ico.free;
end;
end; // pic2str

function str2pic(s: RawByteString):integer;
var
png: TPNGImage;
bmp: TBitmap;
begin
for result:=0 to mainfrm.images.count-1 do
if pic2str(result) = s then
exit;
// in case the pic was not found, it automatically adds it to the pool
png := stringToPNG(s);
try
bmp := TBitmap.Create;
bmp.Assign(png);
result := mainfrm.images.addMasked(bmp, bmp.TransparentColor);
etags.values['icon.'+intToStr(result)] := MD5PassHS(s);
finally
bmp.Free;
png.free
end;
end; // str2pic
{$ENDIF HFS_GIF_IMAGES}

function getImageIndexForFile(fn:string):integer;
var
Expand Down

0 comments on commit 4d719ea

Please sign in to comment.