Add support for basic TGA loading

This commit is contained in:
Benoit Jacquier
2022-08-27 16:07:21 +02:00
parent ecd81e8a53
commit 00f2e911a7
2 changed files with 151 additions and 1 deletions
+6
View File
@@ -61,6 +61,7 @@ Image_Metadata :: union #shared_nil {
^Netpbm_Info,
^PNG_Info,
^QOI_Info,
^TGA_Info,
}
@@ -168,6 +169,7 @@ Error :: union #shared_nil {
General_Image_Error :: enum {
None = 0,
Unsupported_Option,
// File I/O
Unable_To_Read_File,
Unable_To_Write_File,
@@ -390,6 +392,10 @@ TGA_Header :: struct #packed {
}
#assert(size_of(TGA_Header) == 18)
TGA_Info :: struct {
header: TGA_Header,
}
// Function to help with image buffer calculations
compute_buffer_size :: proc(width, height, channels, depth: int, extra_row_bytes := int(0)) -> (size: int) {
size = ((((channels * width * depth) + 7) >> 3) + extra_row_bytes) * height