From f74e281efadbbd3c042f2f3aed13f0552cd881dd Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 28 Aug 2022 18:25:07 +0200 Subject: Various changes to TGA reader - Style changes - Change ptr usage to slice indexing - Add TGA Footer Also, add `peek_data` with offset to `compress`. --- core/image/common.odin | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'core/image/common.odin') diff --git a/core/image/common.odin b/core/image/common.odin index 7caba4fca..c79344445 100644 --- a/core/image/common.odin +++ b/core/image/common.odin @@ -46,7 +46,7 @@ Image :: struct { height: int, channels: int, depth: int, // Channel depth in bits, typically 8 or 16 - pixels: bytes.Buffer, + pixels: bytes.Buffer `fmt:"-"`, /* Some image loaders/writers can return/take an optional background color. For convenience, we return them as u16 so we don't need to switch on the type @@ -380,7 +380,7 @@ QOI_Info :: struct { TGA_Data_Type :: enum u8 { Uncompressed_RGB = 2, - Compressed_RBB = 10, + Compressed_RBB = 10, } TGA_Header :: struct #packed { @@ -397,8 +397,19 @@ TGA_Header :: struct #packed { } #assert(size_of(TGA_Header) == 18) +New_TGA_Signature :: "TRUEVISION-XFILE.\x00" + +TGA_Footer :: struct #packed { + extension_area_offset: u32le, + developer_directory_offset: u32le, + signature: [18]u8 `fmt:"s"`, // Should match signature if New TGA. +} +#assert(size_of(TGA_Footer) == 26) + TGA_Info :: struct { - header: TGA_Header, + header: TGA_Header, + image_id: string, + footer: Maybe(TGA_Footer), } // Function to help with image buffer calculations -- cgit v1.2.3