#import, file "../src/app/app_clock_host.zi"; // Host functions the storage modules call that a test does not provide. It is // built as a separate root so that no generated header declares them twice. c :: #system_library "c"; HostAllocate :: (size: usize) -> *void #foreign c "malloc"; HostRelease :: (memory: *void) #foreign c "free"; // The media library's previews (Kryon image_preview): without an image // codec, every file decodes as the same 600 by 400 gradient, so a real JPEG // preview is made and checked. #if !#defined(MEDIA_COMPRESSION_REAL_CODEC) { #program_export "ImagePreviewDecode" host_image_preview_decode :: (data: string, file_type: string, width: *s32, height: *s32, channels: *s32, upright: *bool) -> *u8 { unused file_type upright.* = false if data.count < 3 { return null } pixels := cast(*u8)HostAllocate(600 * 400 * 3) if pixels == null { return null } y: s32 = 0 while y < 400 { x: s32 = 0 while x < 600 { at := (y * 600 + x) * 3 pixels[at] = cast(u8)(x * 255 / 599) pixels[at + 1] = cast(u8)(y * 255 / 399) pixels[at + 2] = cast(u8)128 x += 1 } y += 1 } width.* = 600 height.* = 400 channels.* = 3 return pixels } #program_export "ImagePreviewRelease" host_image_preview_release :: (pixels: *u8) { HostRelease(cast(*void)pixels) } }