rm seq[uint8] jpg

This commit is contained in:
Ryan Oldenburg 2022-02-11 15:46:26 -06:00
parent 386cdf4be9
commit 295f5788c9
2 changed files with 5 additions and 9 deletions

View file

@ -6,7 +6,7 @@ when defined(pixieUseStb):
const
jpgStartOfImage* = [0xFF.uint8, 0xD8]
proc decodeJpg*(data: seq[uint8]): Image {.raises: [PixieError].} =
proc decodeJpg*(data: string): Image {.inline, raises: [PixieError].} =
## Decodes the JPEG into an Image.
when not defined(pixieUseStb):
raise newException(PixieError, "Decoding JPG requires -d:pixieUseStb")
@ -19,10 +19,6 @@ proc decodeJpg*(data: seq[uint8]): Image {.raises: [PixieError].} =
result = newImage(width, height)
copyMem(result.data[0].addr, pixels[0].unsafeAddr, pixels.len)
proc decodeJpg*(data: string): Image {.inline, raises: [PixieError].} =
## Decodes the JPEG data into an Image.
decodeJpg(cast[seq[uint8]](data))
proc encodeJpg*(image: Image): string {.raises: [PixieError].} =
## Encodes Image into a JPEG data string.
raise newException(PixieError, "Encoding JPG not supported yet")

View file

@ -11,17 +11,17 @@ proc stbi_image_free(retval_from_stbi_load: pointer)
{.importc: "stbi_image_free", stbcall.}
proc stbi_load_from_memory(
buffer: ptr cuchar,
buffer: pointer,
len: cint,
x, y, channels_in_file: var cint,
desired_channels: cint
): ptr cuchar
): pointer
{.importc: "stbi_load_from_memory", stbcall.}
proc loadFromMemory*(buffer: seq[uint8], width, height: var int): seq[uint8] =
proc loadFromMemory*(buffer: string, width, height: var int): string =
var outWidth, outHeight, outComponents: cint
let data = stbi_load_from_memory(
cast[ptr cuchar](buffer[0].unsafeAddr),
buffer[0].unsafeAddr,
buffer.len.cint,
outWidth,
outHeight,