rm seq[uint8] jpg
This commit is contained in:
parent
386cdf4be9
commit
295f5788c9
2 changed files with 5 additions and 9 deletions
|
@ -6,7 +6,7 @@ when defined(pixieUseStb):
|
||||||
const
|
const
|
||||||
jpgStartOfImage* = [0xFF.uint8, 0xD8]
|
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.
|
## Decodes the JPEG into an Image.
|
||||||
when not defined(pixieUseStb):
|
when not defined(pixieUseStb):
|
||||||
raise newException(PixieError, "Decoding JPG requires -d: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)
|
result = newImage(width, height)
|
||||||
copyMem(result.data[0].addr, pixels[0].unsafeAddr, pixels.len)
|
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].} =
|
proc encodeJpg*(image: Image): string {.raises: [PixieError].} =
|
||||||
## Encodes Image into a JPEG data string.
|
## Encodes Image into a JPEG data string.
|
||||||
raise newException(PixieError, "Encoding JPG not supported yet")
|
raise newException(PixieError, "Encoding JPG not supported yet")
|
||||||
|
|
|
@ -11,17 +11,17 @@ proc stbi_image_free(retval_from_stbi_load: pointer)
|
||||||
{.importc: "stbi_image_free", stbcall.}
|
{.importc: "stbi_image_free", stbcall.}
|
||||||
|
|
||||||
proc stbi_load_from_memory(
|
proc stbi_load_from_memory(
|
||||||
buffer: ptr cuchar,
|
buffer: pointer,
|
||||||
len: cint,
|
len: cint,
|
||||||
x, y, channels_in_file: var cint,
|
x, y, channels_in_file: var cint,
|
||||||
desired_channels: cint
|
desired_channels: cint
|
||||||
): ptr cuchar
|
): pointer
|
||||||
{.importc: "stbi_load_from_memory", stbcall.}
|
{.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
|
var outWidth, outHeight, outComponents: cint
|
||||||
let data = stbi_load_from_memory(
|
let data = stbi_load_from_memory(
|
||||||
cast[ptr cuchar](buffer[0].unsafeAddr),
|
buffer[0].unsafeAddr,
|
||||||
buffer.len.cint,
|
buffer.len.cint,
|
||||||
outWidth,
|
outWidth,
|
||||||
outHeight,
|
outHeight,
|
||||||
|
|
Loading…
Reference in a new issue