index 0ab28a5586e623ebc0580fdfca4cff372e36e060..32a4da1d8b8c96597489e82f5474cb9f50f438ab 100644 (file)
StdCtrls, ExtCtrls, utils, Imaging, ImagingTypes, ImagingUtility;
type
+
+ { TAddTextureForm }
+
TAddTextureForm = class (TAddResourceForm)
+ lStats: TLabel;
PanelTexPreview: TPanel;
iPreview: TImage;
eTextureName: TEdit;
var
AddTextureForm: TAddTextureForm;
+ NumFrames: Integer = 0;
function IsAnim(Res: String): Boolean;
function GetFrame(Res: String; var Data: Pointer; var DataLen: Integer;
Exit;
end;
-// Ищем в них описание анимации - "AINM":
+// Ищем в них описание анимации - "ANIM":
ok := False;
for a := 0 to High(Resources) do
if Resources[a] = 'ANIM' then
var
img: TImageData;
clr: TColor32Rec;
- bgc: Byte;
+ bgc: TColor32Rec;
ii: PByte;
Width,
Height: Integer;
// HACK: Lazarus's TBitMap doesn't seem to have a working 32 bit mode, so
// mix color with checkered background. Also, can't really read
// CHECKERS.tga from here. FUCK!
- if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then
- bgc := 255
+ if UseCheckerboard then
+ begin
+ if (((x shr 3) and 1) = 0) xor (((y shr 3) and 1) = 0) then
+ bgc.Color := $FDFDFD
+ else
+ bgc.Color := $CBCBCB;
+ end
else
- bgc := 200;
- clr.r := ClampToByte((Byte(255 - clr.a) * bgc + clr.a * clr.r) div 255);
- clr.g := ClampToByte((Byte(255 - clr.a) * bgc + clr.a * clr.g) div 255);
- clr.b := ClampToByte((Byte(255 - clr.a) * bgc + clr.a * clr.b) div 255);
+ begin
+ bgc.r := GetRValue(PreviewColor);
+ bgc.g := GetGValue(PreviewColor);
+ bgc.b := GetBValue(PreviewColor);
+ end;
+ clr.r := ClampToByte((Byte(255 - clr.a) * bgc.r + clr.a * clr.r) div 255);
+ clr.g := ClampToByte((Byte(255 - clr.a) * bgc.g + clr.a * clr.g) div 255);
+ clr.b := ClampToByte((Byte(255 - clr.a) * bgc.b + clr.a * clr.b) div 255);
// TODO: check for RGB/BGR somehow?
ii^ := clr.b; Inc(ii);
ii^ := clr.g; Inc(ii);
ii^ := clr.r; Inc(ii);
+
+ (* Why this works in linux? *)
+ {$IFNDEF WINDOWS}Inc(ii){$ENDIF}
end;
end;
FreeImage(img);
// Читаем лист текстур:
WAD.GetResource('TEXTURES', config.ReadStr('', 'resource', ''), TextureData, Len);
+ NumFrames := config.ReadInt('', 'framecount', 0);
if (TextureData <> nil) and
(WAD.GetLastError = DFWAD_NOERROR) then
begin
Inherited;
+ lStats.Caption := '';
cbWADList.Items.Add(_lc[I_WAD_SPECIAL_TEXS]);
eTextureName.Text := '';
var
Texture: TBitMap;
wad: String;
+ Anim: Boolean;
begin
Inherited;
+ lStats.Caption := '';
if lbResourcesList.ItemIndex = -1 then
Exit;
if FResourceName = '' then
if wad = _lc[I_WAD_SPECIAL_TEXS] then
Exit;
- if IsAnim(FFullResourceName) then
+ Anim := IsAnim(FFullResourceName);
+ if Anim then
Texture := ShowAnim(FFullResourceName)
else
Texture := ShowTGATexture(FFullResourceName);
if Texture = nil then
Exit;
+
+ if Anim then
+ lStats.Caption := Format(_lc[I_CAP_ANIMATION], [Texture.Width, Texture.Height, NumFrames])
+ else
+ lStats.Caption := Format(_lc[I_CAP_TEXTURE], [Texture.Width, Texture.Height]);
+
iPreview.Canvas.FillRect(iPreview.Canvas.ClipRect);
iPreview.Canvas.CopyRect(Texture.Canvas.ClipRect, Texture.Canvas, Texture.Canvas.ClipRect);
Texture.Free();