Skip to content

Function for telling the name of a pixel format #227

@amigalemming

Description

@amigalemming

I like to have a function that returns a human readable name for the pixel format like so:

pixelFormatName :: Juicy.DynamicImage -> String
pixelFormatName pic =
   case pic of
      Juicy.ImageY8 _ -> "Greyscale 8-bit"
      Juicy.ImageY16 _ -> "Greyscale 16-bit"
      Juicy.ImageY32 _ -> "Greyscale 32-bit"
      Juicy.ImageYF _ -> "Greyscale Floating Point"
      Juicy.ImageYA8 _ -> "Luminance + Alpha 8-bit"
      Juicy.ImageYA16 _ -> "Luminance + Alpha 16-bit"
      Juicy.ImageRGB8 _ -> "RGB 8-bit"
      Juicy.ImageRGB16 _ -> "RGB 16-bit"
      Juicy.ImageRGBA8 _ -> "RGBA 8-bit"
      Juicy.ImageRGBA16 _ -> "RGBA 16-bit"
      Juicy.ImageYCbCr8 _ -> "YCbCr 8-bit"
      Juicy.ImageCMYK8 _ -> "CMYK 8-bit"
      Juicy.ImageCMYK16 _ -> "CMYK 16-bit"
      Juicy.ImageRGBF _ -> "RGB Floating Point"

undefinedImage :: Juicy.Image a
undefinedImage = error "no image"

I want to use this to tell people that I encountered a format that I do not support. I propose to add also undefinedImage in order to tell a format that I support. I can write this function on my own but I have to adapt it to every future extension of the DynamicImage enumeration that I do not support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions