Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/image/png/png.odin
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ read_header :: proc(ctx: ^$C) -> (image.PNG_IHDR, Error) {
header := (^image.PNG_IHDR)(raw_data(c.data))^
// Validate IHDR
using header
if width == 0 || height == 0 || u128(width) * u128(height) > image.MAX_DIMENSIONS {
if width == 0 || height == 0 {
return {}, .Invalid_Image_Dimensions
}

if u128(width) * u128(height) > image.MAX_DIMENSIONS {
return {}, .Image_Dimensions_Too_Large
}

if compression_method != 0 {
return {}, compress.General_Error.Unknown_Compression_Method
}
Expand Down
7 changes: 5 additions & 2 deletions core/image/tga/tga.odin
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
// Intentionally blank
case .Uncompressed_Black_White:
black_white = true
dest_depth = 24
dest_depth = 8 if .do_not_expand_grayscale in options else 24
case .Uncompressed_Color_Mapped:
color_mapped = true
case .Compressed_Color_Mapped:
Expand All @@ -162,7 +162,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
case .Compressed_Black_White:
black_white = true
rle_encoding = true
dest_depth = 24
dest_depth = 8 if .do_not_expand_grayscale in options else 24

case:
return nil, .Unsupported_Format
Expand All @@ -181,6 +181,9 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
}

switch dest_depth {
case 8: // R8
src_channels = 1
dest_channels = 1
case 15: // B5G5R5
src_channels = 2
dest_channels = 3
Expand Down
Loading