adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
529 stars 128 forks source link

simpledisplay: Sprite.takeScreenshot() returns a completely black MemoryImage #432

Open TheZipCreator opened 7 months ago

TheZipCreator commented 7 months ago

Sprite's takeScreenshot() function returns an entirely black TrueColorImage. It should just return an image containing what was on the sprite. This works correctly on Linux, but not on Windows

example code:

import arsd.simpledisplay, arsd.png;

void main() {
    auto win = new SimpleWindow(500, 500, "Test");
    auto img = Image.fromMemoryImage(readPng("./smiley.png")); // replace "./smiley.png" with a path to an image on your computer
    auto sprite = new Sprite(win, img);
    auto sprite2 = Sprite.fromMemoryImage(win, sprite.takeScreenshot(), true); // *should* just copy the data in the other sprite
    scope(exit) {
        sprite.dispose();
        sprite2.dispose();
    }
    win.eventLoop(10, delegate() {
        auto sp = win.draw;
        // this should be two copies of the same image, but on Windows it doesn't work
        sprite.drawAt(sp, Point(0, 0));
        sprite2.drawAt(sp, Point(100, 0));
    });
}
adamdruppe commented 7 months ago

I might have only implemented it on windows themselves, will need to check if it does win32 bitmap copy too (which is an easy operation but ... maybe i missed a spot)