MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / onLoad

Method onLoad

src/app/file/she_format.cpp:49–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47static FileFormat::Regular<SheFormat> ff{"she"};
48
49bool SheFormat::onLoad(FileOp* fop)
50{
51 try {
52 auto surface = std::shared_ptr<she::Surface>(she::instance()->loadRgbaSurface(fop->filename().c_str()));
53 auto width = surface->width();
54 auto height = surface->height();
55 Image* image = fop->sequenceImage(IMAGE_RGB, width, height);
56 for (int y = 0; y < height; ++y) {
57 for (int x = 0; x < width; ++x) {
58 auto c = surface->getPixel(x, y);
59 auto r = gfx::getr(c);
60 auto g = gfx::getg(c);
61 auto b = gfx::getb(c);
62 auto a = gfx::geta(c);
63 put_pixel(image, x, y, doc::rgba(r,g,b,a));
64 }
65 }
66 return true;
67 } catch (...) {}
68
69 return false;
70}
71
72} // namespace app

Callers

nothing calls this directly

Calls 13

instanceFunction · 0.85
getrFunction · 0.85
getgFunction · 0.85
getbFunction · 0.85
getaFunction · 0.85
put_pixelFunction · 0.85
loadRgbaSurfaceMethod · 0.80
rgbaFunction · 0.50
filenameMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
sequenceImageMethod · 0.45

Tested by

no test coverage detected