X-Git-Url: https://deadsoftware.ru/gitweb?p=d2df-editor.git;a=blobdiff_plain;f=src%2Feditor%2Ff_addresource_texture.pas;h=6c3840d627d290c4dd44f1261a09c24a7f377031;hp=7319645ffb72f1498a60a801089c0f8b25c3a1fe;hb=b5f9c55a34f89cc238eedc5f0c2620a2d8ba6687;hpb=2dcab5faef50c93ec6891362b947288f34362081 diff --git a/src/editor/f_addresource_texture.pas b/src/editor/f_addresource_texture.pas index 7319645..6c3840d 100644 --- a/src/editor/f_addresource_texture.pas +++ b/src/editor/f_addresource_texture.pas @@ -7,8 +7,7 @@ interface uses LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, f_addresource, - StdCtrls, ExtCtrls, utils, Imaging, ImagingTypes, ImagingUtility, - e_log; + StdCtrls, ExtCtrls, utils, Imaging, ImagingTypes, ImagingUtility; type TAddTextureForm = class (TAddResourceForm) @@ -47,20 +46,6 @@ uses BinEditor, WADEDITOR, WADSTRUCT, f_main, g_textures, CONFIG, g_map, g_language; -type - TTGAHeader = packed record - FileType: Byte; - ColorMapType: Byte; - ImageType: Byte; - ColorMapSpec: Array [0..4] of Byte; - OrigX: Array [0..1] of Byte; - OrigY: Array [0..1] of Byte; - Width: Array [0..1] of Byte; - Height: Array [0..1] of Byte; - BPP: Byte; - ImageInfo: Byte; - end; - {$R *.lfm} function IsAnim(Res: String): Boolean; @@ -248,19 +233,14 @@ begin end; function CreateBitMap(Data: Pointer; DataSize: Cardinal): TBitMap; -const - BG_R: Byte = 255; - BG_G: Byte = 0; - BG_B: Byte = 255; var img: TImageData; clr: TColor32Rec; + bgc: Byte; ii: PByte; Width, Height: Integer; - ColorDepth: Integer; - ImageSize: Integer; - i, x, y: Integer; + x, y: Integer; BitMap: TBitMap; begin @@ -268,15 +248,10 @@ begin InitImage(img); if not LoadImageFromMemory(Data, DataSize, img) then - begin - e_WriteLog('Invalid image format?', MSG_WARNING); Exit; - end; Width := img.width; Height := img.height; - ColorDepth := 24; - ImageSize := Width*Height*(ColorDepth div 8); BitMap := TBitMap.Create(); BitMap.PixelFormat := pf24bit; @@ -292,18 +267,22 @@ begin begin clr := GetPixel32(img, x, y); // HACK: Lazarus's TBitMap doesn't seem to have a working 32 bit mode, so - // mix color with pink background. FUCK! - clr.r := ClampToByte(((255 - clr.a) * BG_R + clr.a * clr.r) div 255); - clr.g := ClampToByte(((255 - clr.a) * BG_G + clr.a * clr.g) div 255); - clr.b := ClampToByte(((255 - clr.a) * BG_B + clr.a * clr.b) div 255); - // TODO: check for ARGB/RGBA/BGRA/ABGR somehow? + // 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 + else + bgc := 200; + clr.r := ClampToByte(((255 - clr.a) * bgc + clr.a * clr.r) div 255); + clr.g := ClampToByte(((255 - clr.a) * bgc + clr.a * clr.g) div 255); + clr.b := ClampToByte(((255 - clr.a) * bgc + 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); - // ii^ := clr.a; Inc(ii); end; end; - + FreeImage(img); Result := BitMap; end; @@ -509,7 +488,7 @@ begin for i := 0 to lbResourcesList.Count-1 do if lbResourcesList.Selected[i] then begin - AddTexture(utf2win(cbWADlist.Text), utf2win(cbSectionsList.Text), + AddTexture(cbWADlist.Text, utf2win(cbSectionsList.Text), utf2win(lbResourcesList.Items[i]), False); lbResourcesList.Selected[i] := False; end;