本文整理了Java中org.lwjgl.glfw.GLFW.glfwSetWindowIcon()
方法的一些代码示例,展示了GLFW.glfwSetWindowIcon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwSetWindowIcon()
方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwSetWindowIcon
[英]Sets the icon for the specified window.
This function sets the icon of the specified window. If passed an array of candidate images, those of or closest to the sizes desired by the system are selected. If no images are specified, the window reverts to its default icon.
The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits per channel with the red channel first. They are arranged canonically as packed sequential rows, starting from the top-left corner.
The desired image sizes varies depending on platform and system settings. The selected images will be rescaled as needed. Good sizes include 16x16, 32x32 and 48x48.
Notes:
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Set custom icons to the window of this application.
*/
protected void setWindowIcon(final AppSettings settings) {
final Object[] icons = settings.getIcons();
if (icons == null) return;
final GLFWImage[] images = imagesToGLFWImages(icons);
try (final GLFWImage.Buffer iconSet = GLFWImage.malloc(images.length)) {
for (int i = images.length - 1; i >= 0; i--) {
final GLFWImage image = images[i];
iconSet.put(i, image);
}
glfwSetWindowIcon(window, iconSet);
}
}
代码示例来源:origin: libgdx/libgdx
static void setIcon(long windowHandle, Pixmap[] images) {
if (SharedLibraryLoader.isMac)
return;
GLFWImage.Buffer buffer = GLFWImage.malloc(images.length);
Pixmap[] tmpPixmaps = new Pixmap[images.length];
for (int i = 0; i < images.length; i++) {
Pixmap pixmap = images[i];
if (pixmap.getFormat() != Pixmap.Format.RGBA8888) {
Pixmap rgba = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Pixmap.Format.RGBA8888);
rgba.setBlending(Pixmap.Blending.None);
rgba.drawPixmap(pixmap, 0, 0);
tmpPixmaps[i] = rgba;
pixmap = rgba;
}
GLFWImage icon = GLFWImage.malloc();
icon.set(pixmap.getWidth(), pixmap.getHeight(), pixmap.getPixels());
buffer.put(icon);
icon.free();
}
buffer.position(0);
GLFW.glfwSetWindowIcon(windowHandle, buffer);
buffer.free();
for (Pixmap pixmap : tmpPixmaps) {
if (pixmap != null) {
pixmap.dispose();
}
}
}
代码示例来源:origin: libgdx/libgdx
static void setIcon(long windowHandle, Pixmap[] images) {
if (SharedLibraryLoader.isMac)
return;
GLFWImage.Buffer buffer = GLFWImage.malloc(images.length);
Pixmap[] tmpPixmaps = new Pixmap[images.length];
for (int i = 0; i < images.length; i++) {
Pixmap pixmap = images[i];
if (pixmap.getFormat() != Pixmap.Format.RGBA8888) {
Pixmap rgba = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Pixmap.Format.RGBA8888);
rgba.setBlending(Pixmap.Blending.None);
rgba.drawPixmap(pixmap, 0, 0);
tmpPixmaps[i] = rgba;
pixmap = rgba;
}
GLFWImage icon = GLFWImage.malloc();
icon.set(pixmap.getWidth(), pixmap.getHeight(), pixmap.getPixels());
buffer.put(icon);
icon.free();
}
buffer.position(0);
GLFW.glfwSetWindowIcon(windowHandle, buffer);
buffer.free();
for (Pixmap pixmap : tmpPixmaps) {
if (pixmap != null) {
pixmap.dispose();
}
}
}
代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3
/**
* Set custom icons to the window of this application.
*/
protected void setWindowIcon(final AppSettings settings) {
final Object[] icons = settings.getIcons();
if (icons == null) return;
final GLFWImage[] images = imagesToGLFWImages(icons);
try (final GLFWImage.Buffer iconSet = GLFWImage.malloc(images.length)) {
for (int i = images.length - 1; i >= 0; i--) {
final GLFWImage image = images[i];
iconSet.put(i, image);
}
glfwSetWindowIcon(window, iconSet);
}
}
代码示例来源:origin: sriharshachilakapati/SilenceEngine
glfwImage.pixels(data);
glfwSetWindowIcon(handle, glfwImages);
代码示例来源:origin: Renanse/Ardor3D
public void setIcon(final Image[] iconImages) {
if (iconImages.length == 0) {
throw new IllegalArgumentException("Must have at least one icon image. Only the first is used.");
}
Image image = iconImages[0];
if (image.getDataType() != PixelDataType.UnsignedByte) {
throw new Ardor3dException("Your icon is in a format that could not be converted to UnsignedByte - RGBA");
}
if (image.getDataFormat() != ImageDataFormat.RGBA) {
if (image.getDataFormat() != ImageDataFormat.RGB) {
throw new Ardor3dException(
"Your icon is in a format that could not be converted to UnsignedByte - RGBA");
}
image = _RGB888_to_RGBA8888(image);
}
final ByteBuffer iconData = image.getData(0);
iconData.rewind();
final GLFWImage img = GLFWImage.malloc();
final GLFWImage.Buffer imagebf = GLFWImage.malloc(1);
img.set(image.getWidth(), image.getHeight(), iconData);
imagebf.put(0, img);
GLFW.glfwSetWindowIcon(_windowId, imagebf);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3
static void setIcon(long windowHandle, Pixmap[] images) {
if (SharedLibraryLoader.isMac)
return;
GLFWImage.Buffer buffer = GLFWImage.malloc(images.length);
Pixmap[] tmpPixmaps = new Pixmap[images.length];
for (int i = 0; i < images.length; i++) {
Pixmap pixmap = images[i];
if (pixmap.getFormat() != Pixmap.Format.RGBA8888) {
Pixmap rgba = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Pixmap.Format.RGBA8888);
rgba.setBlending(Pixmap.Blending.None);
rgba.drawPixmap(pixmap, 0, 0);
tmpPixmaps[i] = rgba;
pixmap = rgba;
}
GLFWImage icon = GLFWImage.malloc();
icon.set(pixmap.getWidth(), pixmap.getHeight(), pixmap.getPixels());
buffer.put(icon);
icon.free();
}
buffer.position(0);
GLFW.glfwSetWindowIcon(windowHandle, buffer);
buffer.free();
for (Pixmap pixmap : tmpPixmaps) {
if (pixmap != null) {
pixmap.dispose();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!