/** * 将当前游戏截屏转化为纹理 * * @param x * @param y * @param width * @param height * @return */ public static synchronized LTexture toScreenCaptureTexture(int x, int y, int width, int height) { if (GLEx.gl10 == null) { return null; } LImage temp = toScreenCaptureImage(x, y, width, height); LTexture texture = new LTexture(GLLoader.getTextureData(temp), Format.LINEAR); if (temp != null && !temp.isClose()) { temp.dispose(); temp = null; } return texture; }
@Override public void dispose() { buffer = null; drawPixels = null; runnable = null; if (image != null) { image.dispose(); image = null; } if (commit != null) { commit.dispose(); commit = null; } }
/** * 绘制一个RMVX样式的游标 * * @return */ public static LTexture makeCursor(int w, int h) { LImage cursor = LImage.createImage(w, h, true); LGraphics g = cursor.getLGraphics(); g.setColor(0, 0, 0, 255); g.fillRect(0, 0, w, h); g.setColor(255, 255, 255, 255); g.fillRect(1, 1, w - 2, h - 2); g.setColor(0, 0, 0, 255); g.fillRect(4, 4, w - 8, h - 8); g.setColor(0, 0, 0, 255); g.fillRect(w / 4, 0, w / 2, h); g.setColor(0, 0, 0, 255); g.fillRect(0, h / 4, w, h / 2); g.dispose(); g = null; int[] basePixels = cursor.getPixels(); int length = basePixels.length; int c = LColor.black.getRGB(); for (int i = 0; i < length; i++) { if (basePixels[i] == c) { basePixels[i] = 0xffffff; } } cursor.setPixels(basePixels, w, h); LTexture texture = cursor.getTexture(); if (cursor != null) { cursor.dispose(); cursor = null; } return texture; }