commit
379abcb638
2 changed files with 18 additions and 11 deletions
|
@ -1,10 +1,16 @@
|
||||||
import pixie/images, pixie/common, pixie/fileformats/stb_image/stb_image
|
import pixie/images, pixie/common
|
||||||
|
|
||||||
|
when defined(pixieUseStb):
|
||||||
|
import pixie/fileformats/stb_image/stb_image
|
||||||
|
|
||||||
const
|
const
|
||||||
jpgStartOfImage* = [0xFF.uint8, 0xD8]
|
jpgStartOfImage* = [0xFF.uint8, 0xD8]
|
||||||
|
|
||||||
proc decodeJpg*(data: seq[uint8]): Image =
|
proc decodeJpg*(data: seq[uint8]): Image =
|
||||||
## Decodes the JPEG into an Image.
|
## Decodes the JPEG into an Image.
|
||||||
|
when not defined(pixieUseStb):
|
||||||
|
raise newException(PixieError, "Decoding JPG requires -d:pixieUseStb")
|
||||||
|
else:
|
||||||
var
|
var
|
||||||
width: int
|
width: int
|
||||||
height: int
|
height: int
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import pixie/fileformats/jpg
|
when defined(pixieUseStb):
|
||||||
|
import pixie/fileformats/jpg
|
||||||
|
|
||||||
let
|
let
|
||||||
original = readFile("tests/images/jpg/jpeg420exif.jpg")
|
original = readFile("tests/images/jpg/jpeg420exif.jpg")
|
||||||
stbDecoded = decodeJpg(original)
|
stbDecoded = decodeJpg(original)
|
||||||
|
|
Loading…
Reference in a new issue