Freezing when loading png (manjaro linux)
I am having a lot of fun with raster. It is super nice to use. However there is this small annoying thing that happens when i try to load a .png file with the raster::open function. The program stops and my fan spins up like crazy. If you have any idea what is going on then i would love to know.
I have the same problem when loading 24-bit RGB PNGs, it works fine with 32-bit RGB+alpha PNGs. On my laptop it takes ~100 seconds to load (1280x1280, 24-bit RGB, non-interlaced, 84.7%) and ~ 75ms to load (1280x1280, 32-bit RGB+alpha, non-interlaced, 70.3%)
if info.color_type == png::ColorType::RGB {
// Applies only to RGB
let mut insert_count = 0;
let len = (info.width * info.height) as usize;
for i in 0..len {
// TODO: This is slow!
let insert_pos = 3 * (i + 1) + insert_count;
bytes.insert(insert_pos, 255);
insert_count += 1;
}
} // TODO other ::ColorType
this is probably the cause, already annotated with a todo
The original algorithm for extending from RGB to RGBA is probably O(n^2), mine should be O(n)