Rename FileFormat enum.
This commit is contained in:
parent
b456c54825
commit
e9f9b82bd4
1 changed files with 18 additions and 18 deletions
|
@ -8,7 +8,7 @@ export bumpy, chroma, common, contexts, fonts, images, masks, paints, paths, vma
|
||||||
|
|
||||||
type
|
type
|
||||||
FileFormat* = enum
|
FileFormat* = enum
|
||||||
ffPng, ffBmp, ffJpg, ffGif, ffQoi, ffPpm
|
FormatPng, FormatBmp, FormatJpg, FormatGif, FormatQoi, FormatPpm
|
||||||
|
|
||||||
converter autoStraightAlpha*(c: ColorRGBX): ColorRGBA {.inline, raises: [].} =
|
converter autoStraightAlpha*(c: ColorRGBX): ColorRGBA {.inline, raises: [].} =
|
||||||
## Convert a premultiplied alpha RGBA to a straight alpha RGBA.
|
## Convert a premultiplied alpha RGBA to a straight alpha RGBA.
|
||||||
|
@ -62,23 +62,23 @@ proc readMask*(filePath: string): Mask {.raises: [PixieError].} =
|
||||||
proc encodeImage*(image: Image, fileFormat: FileFormat): string {.raises: [PixieError].} =
|
proc encodeImage*(image: Image, fileFormat: FileFormat): string {.raises: [PixieError].} =
|
||||||
## Encodes an image into memory.
|
## Encodes an image into memory.
|
||||||
case fileFormat:
|
case fileFormat:
|
||||||
of ffPng:
|
of FormatPng:
|
||||||
image.encodePng()
|
image.encodePng()
|
||||||
of ffJpg:
|
of FormatJpg:
|
||||||
image.encodeJpg()
|
image.encodeJpg()
|
||||||
of ffBmp:
|
of FormatBmp:
|
||||||
image.encodeBmp()
|
image.encodeBmp()
|
||||||
of ffQoi:
|
of FormatQoi:
|
||||||
image.encodeQoi()
|
image.encodeQoi()
|
||||||
of ffGif:
|
of FormatGif:
|
||||||
raise newException(PixieError, "Unsupported file format")
|
raise newException(PixieError, "Unsupported file format")
|
||||||
of ffPpm:
|
of FormatPpm:
|
||||||
image.encodePpm()
|
image.encodePpm()
|
||||||
|
|
||||||
proc encodeMask*(mask: Mask, fileFormat: FileFormat): string {.raises: [PixieError].} =
|
proc encodeMask*(mask: Mask, fileFormat: FileFormat): string {.raises: [PixieError].} =
|
||||||
## Encodes a mask into memory.
|
## Encodes a mask into memory.
|
||||||
case fileFormat:
|
case fileFormat:
|
||||||
of ffPng:
|
of FormatPng:
|
||||||
mask.encodePng()
|
mask.encodePng()
|
||||||
else:
|
else:
|
||||||
raise newException(PixieError, "Unsupported file format")
|
raise newException(PixieError, "Unsupported file format")
|
||||||
|
@ -86,11 +86,11 @@ proc encodeMask*(mask: Mask, fileFormat: FileFormat): string {.raises: [PixieErr
|
||||||
proc writeFile*(image: Image, filePath: string) {.raises: [PixieError].} =
|
proc writeFile*(image: Image, filePath: string) {.raises: [PixieError].} =
|
||||||
## Writes an image to a file.
|
## Writes an image to a file.
|
||||||
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
|
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
|
||||||
of ".png": ffPng
|
of ".png": FormatPng
|
||||||
of ".bmp": ffBmp
|
of ".bmp": FormatBmp
|
||||||
of ".jpg", ".jpeg": ffJpg
|
of ".jpg", ".jpeg": FormatJpg
|
||||||
of ".qoi": ffQoi
|
of ".qoi": FormatQoi
|
||||||
of ".ppm": ffPpm
|
of ".ppm": FormatPpm
|
||||||
else:
|
else:
|
||||||
raise newException(PixieError, "Unsupported file extension")
|
raise newException(PixieError, "Unsupported file extension")
|
||||||
|
|
||||||
|
@ -102,11 +102,11 @@ proc writeFile*(image: Image, filePath: string) {.raises: [PixieError].} =
|
||||||
proc writeFile*(mask: Mask, filePath: string) {.raises: [PixieError].} =
|
proc writeFile*(mask: Mask, filePath: string) {.raises: [PixieError].} =
|
||||||
## Writes a mask to a file.
|
## Writes a mask to a file.
|
||||||
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
|
let fileFormat = case splitFile(filePath).ext.toLowerAscii():
|
||||||
of ".png": ffPng
|
of ".png": FormatPng
|
||||||
of ".bmp": ffBmp
|
of ".bmp": FormatBmp
|
||||||
of ".jpg", ".jpeg": ffJpg
|
of ".jpg", ".jpeg": FormatJpg
|
||||||
of ".qoi": ffQoi
|
of ".qoi": FormatQoi
|
||||||
of ".ppm": ffPpm
|
of ".ppm": FormatPpm
|
||||||
else:
|
else:
|
||||||
raise newException(PixieError, "Unsupported file extension")
|
raise newException(PixieError, "Unsupported file extension")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue