fixed deskop shader stuff.
This commit is contained in:
@@ -9,30 +9,31 @@ import com.badlogic.gdx.backends.iosrobovm.*;
|
||||
|
||||
public class Saver {
|
||||
|
||||
public static Pixmap takeScreenshot(){
|
||||
public static Pixmap flipPixmap(Pixmap src) {
|
||||
final int width = src.getWidth();
|
||||
final int height = src.getHeight();
|
||||
Pixmap flipped = new Pixmap(width, height, src.getFormat());
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
flipped.drawPixel(x, y, src.getPixel(x, height - y -1));
|
||||
}
|
||||
}
|
||||
return flipped;
|
||||
}
|
||||
|
||||
public static UIImage takeScreenshot(){
|
||||
|
||||
UIImage newImage;
|
||||
UIGraphics.beginImageContext(new CGSize(1280, 960));
|
||||
((IOSApplication) Gdx.app).getUIViewController().getView().drawViewHierarchy(
|
||||
new CGRect(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()) , true);
|
||||
//((IOSApplication) Gdx.app).getUIViewController().getView().setTransform(CGAffineTransform.createScale(1, -1));
|
||||
UIView view = ((IOSApplication) Gdx.app).getUIViewController().getView();
|
||||
UIGraphics.beginImageContext(new CGSize(view.getFrame().getWidth(), view.getFrame().getHeight()), true, 0.0);
|
||||
view.drawViewHierarchy(
|
||||
new CGRect(0, 0, view.getFrame().getWidth(), view.getFrame().getHeight()), true);
|
||||
newImage = UIGraphics.getImageFromCurrentImageContext();
|
||||
UIGraphics.endImageContext();
|
||||
//((IOSApplication) Gdx.app).getUIViewController().getView().setTransform(CGAffineTransform.createScale(1, 1));
|
||||
return newImage;
|
||||
|
||||
NSData data = newImage.toPNGData();
|
||||
newImage.dispose();
|
||||
|
||||
PixmapIO.PNG p = new PixmapIO.PNG();
|
||||
Pixmap stepResult = new Pixmap(data.getBytes(), 0, data.getBytes().length);
|
||||
p.setFlipY(true);
|
||||
try {
|
||||
p.write(Gdx.files.local("screenshot.png"), stepResult);
|
||||
stepResult.dispose();
|
||||
p.dispose();
|
||||
|
||||
return new Pixmap(Gdx.files.local("screenshot.png"));
|
||||
|
||||
} catch (Exception e) {
|
||||
return new Pixmap(160, 120, Pixmap.Format.RGBA8888);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user