Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small PNGs Getting Skerwed #1

Open
mlaviexc opened this issue Jul 9, 2022 · 2 comments
Open

Small PNGs Getting Skerwed #1

mlaviexc opened this issue Jul 9, 2022 · 2 comments

Comments

@mlaviexc
Copy link

mlaviexc commented Jul 9, 2022

M. Ansel,

I am having problems with small PNGs (smaller than about 400x400). The image appears skewed. The smaller the source PNG, the more it gets skewed.

I would greatly appreciate help with this.

TIA,
Lavie

@JeremyAnsel
Copy link
Owner

Hello,
Can you post a sample code showing how to reproduce the issue?

@mlaviexc
Copy link
Author

mlaviexc commented Jul 10, 2022

Hello M. Ansel,

Thank you for your swift reply.

Late last night, I finally figured it out (I am not an expert at BMP graphics file formats...) .

I didn't know about the rule that BMPs have to have a number of bytes per line which is evenly divisible by 4. Since ARGB can only ever be a multiple of 4 bytes, I'd never encountered the problem.

The problem was that your result, being 1 byte per px, could cause a row size in bytes which was not divisible by 4. The lack of padding was causing each line to be skewed further. Once I provided the padding bytes, it worked.

If I may, I have a suggestion:

Since not everyone who uses your excellent product is an expert at the BMP protocol, you might write documentation which warns programmers about the need to pad to a multiple of 4 bytes per line.

Alternatively, you could accept widthPx and heightPx as input parameters, and you could perform the padding.

In case you would prefer not to do the padding in your code, I would be happy to provide example code for performing the padding for use by others using ColorQuant.

TIA,
Lavie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants