Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Greyscale bug #5

@pdinklag

Description

@pdinklag

I found and fixed a nasty bug regarding greyscale JPEGs. The following condition in the else branch of Image.ConvertYcc is wrong:
https://github.com/JBildstein/NanoJpeg.Net/blob/c200b00cc4b3821303907abbada2508d36ad09a7/NanoJpeg/Image.Convert.cs#L76

If stride and width are equal, greyscale images will not be handled and have the Data field left at null.

The difference between stride and width is checked a few lines below and the case where they are equal is completely fine, and even handled correctly. The condition should rather be:

else if (channels.Length == 1)

Note that this is already a bug in the original NanoJPEG.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions