Describe the bug
I wanted to draw icons on a plot. BitMapElement seemed to be the way to do it, and there was no constructor for it so I used the From<(Coord, image::DynamicImage)> implementation instead. My icon was rather simple; a black cog with a transparent background. However, plotters actually rendered... a completely black square.
At this point I have understood why this happens, but it took me 150 minutes of frustrating debugging work to find the root cause of this issue: https://github.com/38/plotters/blob/master/src/element/image.rs#L171
The problem is that plotters converts images into full-opaque images internally, discarding the transparency information along the way. For that reason, my pretty icon got turned into a black square.
I can think of several possible ways to improve/fix the situation:
instead of From<(Coord, DynamicImage)>, take From<(Coord, DynamicImage, Color)>. Then, don't discard transparency but replace it with the given color instead
(On that note, might as well make a proper constructor BitMapElement::new(Coord, DynamicImage, Color) instead of the From implementation. This kind of use is not what From/Into is meant for)
Describe the bug I wanted to draw icons on a plot. BitMapElement seemed to be the way to do it, and there was no constructor for it so I used the
From<(Coord, image::DynamicImage)>
implementation instead. My icon was rather simple; a black cog with a transparent background. However, plotters actually rendered... a completely black square.At this point I have understood why this happens, but it took me 150 minutes of frustrating debugging work to find the root cause of this issue: https://github.com/38/plotters/blob/master/src/element/image.rs#L171 The problem is that plotters converts images into full-opaque images internally, discarding the transparency information along the way. For that reason, my pretty icon got turned into a black square.
I can think of several possible ways to improve/fix the situation:
From<(Coord, DynamicImage)>
, takeFrom<(Coord, DynamicImage, Color)>
. Then, don't discard transparency but replace it with the given color insteadBitMapElement::new(Coord, DynamicImage, Color)
instead of the From implementation. This kind of use is not what From/Into is meant for)Version Information 0.3.0