You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know what you mean by "automatically decides",tinybmp should display the image like it is stored inside the BMP file. Do you experience a random selection of colors (like some images are inverted and some are not)? There have been some bugs related to this in the past, but I think they should be fixed in current releases.
BinaryColor is a bit of a special case, because BinaryColor::On can be a light pixel (e.g. on an OLED) or a dark pixel (on a LCD). tinybmp maps white pixels to BinaryColor::On and black pixels to BinaryColor::Off.
If you can give me a few more details about your application, like the type of display you are using, and an example BMP file, that isn't drawn like you expect, I will be able to give you a better answer.
I see what you mean and I agree that being able to invert the image for LCDs and EPDs is a useful feature. But I need to think about if I want to include this feature in tinybmp itself.
In the meantime you can use an embedded-graphics DrawTarget adapter to invert all embedded-graphics operations:
@karimpanacci: Did you try the DrawTarget adapter based solution? If that works for you I would prefer to add something similar to the next embedded-graphics release instead of adding color inversion to tinybmp.
@rfuest Hi, I’ve been quite busy of late and forgot to try it out; I’ve just tested it now on the code I was working on and it works.
The only issue is that InvertedTarget required both DrawTarget and OriginDimensions, but I was working on some code that simply had an impl DrawTarget as its input.
So, to use it without having to change all my code, I had to remove OriginDimensions as a constraint.
I’m not sure if that’s correct, because I’ve read that OriginDimensions should be used when the origin is always 0, but I couldn’t change all the code to include OriginDimensions as a constraint as well.
However, it worked – the image color was inverted correctly and everything worked fine.
Activity
rfuest commentedon Jul 27, 2026
I don't know what you mean by "automatically decides",
tinybmpshould display the image like it is stored inside the BMP file. Do you experience a random selection of colors (like some images are inverted and some are not)? There have been some bugs related to this in the past, but I think they should be fixed in current releases.BinaryColoris a bit of a special case, becauseBinaryColor::Oncan be a light pixel (e.g. on an OLED) or a dark pixel (on a LCD).tinybmpmaps white pixels toBinaryColor::Onand black pixels toBinaryColor::Off.If you can give me a few more details about your application, like the type of display you are using, and an example BMP file, that isn't drawn like you expect, I will be able to give you a better answer.
karimpanacci commentedon Jul 27, 2026
@rfuest Yes I was referring only to BinaryColor. I’m using an e-paper display and have set the “On” color to black.
So when I view images with tinybmp, the colors appear reversed.
It would be convenient to be able to choose this behavior.
rfuest commentedon Jul 27, 2026
I see what you mean and I agree that being able to invert the image for LCDs and EPDs is a useful feature. But I need to think about if I want to include this feature in
tinybmpitself.In the meantime you can use an embedded-graphics
DrawTargetadapter to invert all embedded-graphics operations:It can be used like this:
rfuest commentedon Aug 13, 2026
@karimpanacci: Did you try the
DrawTargetadapter based solution? If that works for you I would prefer to add something similar to the nextembedded-graphicsrelease instead of adding color inversion totinybmp.karimpanacci commentedon Aug 13, 2026
@rfuest Hi, I’ve been quite busy of late and forgot to try it out; I’ve just tested it now on the code I was working on and it works.
The only issue is that InvertedTarget required both DrawTarget and OriginDimensions, but I was working on some code that simply had an
impl DrawTargetas its input.So, to use it without having to change all my code, I had to remove OriginDimensions as a constraint.
And I implemented it like this:
I’m not sure if that’s correct, because I’ve read that OriginDimensions should be used when the origin is always 0, but I couldn’t change all the code to include OriginDimensions as a constraint as well.
However, it worked – the image color was inverted correctly and everything worked fine.
This is the full code I used: