summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ead479e)
raw | patch | inline | side by side (parent: ead479e)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 30 Nov 2019 11:31:23 +0000 (14:31 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 30 Nov 2019 11:31:23 +0000 (14:31 +0300) |
src/editor/f_addresource_sky.pas | patch | blob | history | |
src/editor/f_addresource_texture.pas | patch | blob | history |
index 79362df8f84f194d09b5a83da44b128da106b1be..e4a0f44fd86d0fd26a16b09a37572f0773f75e5b 100644 (file)
img: TImageData;
clr: TColor32Rec;
bgc: TColor32Rec;
- ii: PByte;
Width,
Height: Integer;
x, y: Integer;
Width := img.width;
Height := img.height;
-
BitMap := TBitMap.Create();
BitMap.PixelFormat := pf24bit;
-
BitMap.Width := Width;
BitMap.Height := Height;
-
-// Копируем в BitMap:
- ii := BitMap.RawImage.Data;
- for y := 0 to height-1 do
+ for y := 0 to height - 1 do
begin
- for x := 0 to width-1 do
+ for x := 0 to width - 1 do
begin
clr := GetPixel32(img, x, y);
// 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 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
+ 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
- begin
- bgc.r := GetRValue(PreviewColor);
- bgc.g := GetGValue(PreviewColor);
- bgc.b := GetBValue(PreviewColor);
- end;
+ 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;
+ BitMap.Canvas.Pixels[x, y] := RGBToColor(clr.r, clr.g, clr.b)
+ end
end;
FreeMem(TextureData);
FreeImage(img);
index 62d0fd5239877ede9ddf3af790bc81ce02dcae3c..cdd06218b5338bd8c18fc4713f31b29986f30f8f 100644 (file)
end
end;
-function CreateBitMap(Data: Pointer; DataSize: Cardinal): TBitMap;
+function CreateBitMap (Data: Pointer; DataSize: Cardinal): TBitMap;
var
- img: TImageData;
- clr: TColor32Rec;
- bgc: TColor32Rec;
- ii: PByte;
- Width,
- Height: Integer;
- x, y: Integer;
- BitMap: TBitMap;
-
+ img: TImageData;
+ clr, bgc: TColor32Rec;
+ Width, Height: Integer;
+ x, y: Integer;
+ BitMap: TBitMap;
begin
Result := nil;
-
InitImage(img);
if not LoadImageFromMemory(Data, DataSize, img) then
Exit;
Width := img.width;
Height := img.height;
-
BitMap := TBitMap.Create();
- BitMap.PixelFormat := pf24bit;
-
+ BitMap.PixelFormat := pf24bit;
BitMap.Width := Width;
BitMap.Height := Height;
-
-// Копируем в BitMap:
- ii := BitMap.RawImage.Data;
- for y := 0 to height-1 do
+ for y := 0 to Height - 1 do
begin
- for x := 0 to width-1 do
+ for x := 0 to Width - 1 do
begin
clr := GetPixel32(img, x, y);
// 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 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
+ 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
- begin
- bgc.r := GetRValue(PreviewColor);
- bgc.g := GetGValue(PreviewColor);
- bgc.b := GetBValue(PreviewColor);
- end;
+ 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;
+ BitMap.Canvas.Pixels[x, y] := RGBToColor(clr.r, clr.g, clr.b)
+ end
end;
FreeImage(img);
Result := BitMap;