i18n Library automatically include flag's images into output binary like bitmaps, but this format is very hudge.
i'm converted images into JPEG(economy 24 kb) and modify the i18nCtrls.pas see TCustomResFlagImageList class.
Below i've posted a modificated code:
- Code: Select all
{ TCustomResFlagImageList }
function EnumBitmapsCallback(hModule: hModule; lpszType, lpszName: PChar;
lParam: Integer): Integer; stdcall;
var
IL: TCustomResFlagImageList absolute lParam;
ISO_3166_2: string;
begin
if (lpszType = 'JPEG') and (ULONG_PTR(lpszName) shr 16 <> 0) and
(AnsiStrPos(lpszName, PChar(IL.GetResourcePrefix)) = lpszName) then
begin
SetString(ISO_3166_2, lpszName + Length(IL.GetResourcePrefix),
StrLen(lpszName) - Cardinal(Length(IL.GetResourcePrefix)));
IL.AddFlagFromResource(ISO_3166_2, lpszName, hModule);
end;
Result := 1;
end;
function TCustomResFlagImageList.AddFlagFromResource(const ISO_3166_2,
ResName: string; hModule: hModule): Integer;
var
JPEG: TJPEGImage;
RS: TResourceStream;
BMP: TBitmap;
begin
if hModule = 0 then
hModule := HInstance;
JPEG := TJPEGImage.Create;
BMP := TBitmap.Create;
RS := TResourceStream.Create(HInstance, PChar(ResName), PChar('JPEG'));
try
JPEG.LoadFromStream(RS);
BMP.Assign(JPEG);
Result := AddFlag(UpperCase(ISO_3166_2), BMP.Handle);
finally
FreeAndNil(JPEG);
FreeAndNil(BMP);
FreeAndNil(RS);
end;
end;
procedure TCustomResFlagImageList.PrepareFlags;
begin
with GetFlagSize do
SetSize(cx, cy);
EnumResourceNames(HInstance, PChar('JPEG'), @EnumBitmapsCallback,
Integer(Self));
end;
Mod/ images see in attachments.
Also I'm think that the flags images must be stored in language files as a streams, 1 language = 1 flag, not in EXE. But I'm don't understood how it's made.. What you think?