代码和标记问答的示例图像
在准备 上看到,其中包括 2 个其他精灵集(相同不同颜色的图像).
详细信息: 384x128 像素(每个精灵 64x64 像素)PNG,部分透明.
类别: 中所示,最初是作为屏幕截图"开发的' 的屏幕保护程序.
详细信息: 160x120 像素,填充 BG(无透明度)
<块引用>动画水,如 开发的.内"行星的轨道(从水星到木星,在小行星带的厚处显示了一个额外的轨道).在黑暗的 BG 上效果更好.
详细信息: 450x450 &具有透明度的 150x150 像素动画 GIF.
<块引用>图片
日出&澳大利亚悉尼中央商务区上空的月落
日落&金星在澳大利亚堪培拉附近的斯特罗姆洛山上的望远镜.
类别:
瓷砖
这个墨卡托地球地图可以左右平铺.最初在 并从文本中提取 URL.
代码
下面是一个拆分棋子精灵表的 Java 类,适合粘贴到 MCVE:
导入 java.awt.image.*;导入 javax.imageio.*;导入java.net.*;导入java.io.*;导入 java.util.*;公共最终类 ChessSprites {私人 ChessSprites() {}公共静态最终 int SIZE = 64;公共静态最终 BufferedImage SHEET;静止的 {尝试 {//见 https://stackoverflow.com/a/19209651/2891664SHEET = ImageIO.read(new URL("https://i.stack.imgur.com/memI0.png"));} 捕捉(IOException x){抛出新的 UncheckedIOException(x);}}公共静态最终 BufferedImage GOLD_QUEEN = SHEET.getSubimage(0 * SIZE, 0, SIZE, SIZE);公共静态最终 BufferedImage SILVER_QUEEN = SHEET.getSubimage(0 * SIZE, SIZE, SIZE, SIZE);公共静态最终 BufferedImage GOLD_KING = SHEET.getSubimage(1 * SIZE, 0, SIZE, SIZE);公共静态最终 BufferedImage SILVER_KING = SHEET.getSubimage(1 * SIZE, SIZE, SIZE, SIZE);公共静态最终 BufferedImage GOLD_ROOK = SHEET.getSubimage(2 * SIZE, 0, SIZE, SIZE);公共静态最终 BufferedImage SILVER_ROOK = SHEET.getSubimage(2 * SIZE, SIZE, SIZE, SIZE);公共静态最终 BufferedImage GOLD_KNIGHT = SHEET.getSubimage(3 * SIZE, 0, SIZE, SIZE);public static final BufferedImage SILVER_KNIGHT = SHEET.getSubimage(3 * SIZE, SIZE, SIZE, SIZE);公共静态最终 BufferedImage GOLD_BISHOP = SHEET.getSubimage(4 * SIZE, 0, SIZE, SIZE);公共静态最终 BufferedImage SILVER_BISHOP = SHEET.getSubimage(4 * SIZE, SIZE, SIZE, SIZE);公共静态最终 BufferedImage GOLD_PAWN = SHEET.getSubimage(5 * SIZE, 0, SIZE, SIZE);public static final BufferedImage SILVER_PAWN = SHEET.getSubimage(5 * SIZE, SIZE, SIZE, SIZE);公共静态最终列表<BufferedImage>精灵 =Collections.unmodifiableList(Arrays.asList(GOLD_QUEEN, SILVER_QUEEN,GOLD_KING, SILVER_KING,GOLD_ROOK, SILVER_ROOK,GOLD_KNIGHT, SILVER_KNIGHT,GOLD_BISHOP, SILVER_BISHOP,GOLD_PAWN, SILVER_PAWN));}
When preparing an MCVE/SSCCE that involves images, it is useful to have direct access to images.
The types of images that would cover most questions are - small images in multiple colors or shapes, animated GIFs with/without transparency, JPEGs that are 'pairs' of pictures & can be used in image transitions, tile sets, sprite sheets..
Are there any small (under 30KB), on-site, license & royalty free images we can hot-link to for these types of examples?
解决方案Here are some example images for common use, mostly from existing answers on SO.
Icons
Simple Geometric shapes generated using Java as originally seen in this answer. It includes a Java based interface that defines the URLs and makes them easy to access.
Details: 32x32 pixel PNG (4 colors x 5 shapes) with partial transparency (along the edges).
Categories: png icons
Sprite Sheets
Chess Pieces as originally seen on this answer that includes 2 other sprite sets (same image in different colors).
Details: 384x128 px (each sprite 64x64 px) PNG with partial transparency.
Categories: png sprite-sheet icons
Animated
GIF is the only image format that supports animation. Here are a few examples.
Categories: gif animated-gif
Solid BG
Animated dashed border as seen in this answer.
Details: 100x30 px with filled BG (no transparency)
Zooming stars as seen in this answer, originally developed as a 'screen-shot' of a screensaver.
Details: 160x120 px with filled BG (no transparency)
Animated Water as seen in this answer to Animating Tiles In My Game.
Details: 60x60 px with filled BG (no transparency)
Transparent BG
Orbital animation, originally developed for 1.1C. The orbits of the 'inner' planets (from Mercury to Jupiter, with an extra orbit shown in the thick of the asteroid belt). Better on a dark BG.
Details: 450x450 & 150x150 px animated GIFs with transparency.
Pictures
Sunrise & moonset over the CBD of Sydney, Australia
Sunset & Venus over a telescope on Mt Stromlo, near Canberra, Australia.
Categories: jpeg slideshow + Image Transitions
Details: 480x320 px JPEGs x 4. (Displayed here at 1/2 size.)
Panorama at Dawn across the South-Eastern Suburbs of Sydney.
Categories: jpg panoramas animation (scrolling)
Details: 1474x436 px JPEG.
Tiles
This Mercator map of Earth can be tiled left/right. Originally seen on this answer. The answer also includes a second version of the image that shows a semi-transparent line for the equator (which is not in the center, but significantly below it).
Details: 640x316 px (add 44 px at bottom to center equator) PNG with transparent BG.
Categories: png tile animation (scrolling)
Tip
For getting the URLs of the images, you might 'context click' on the image as seen in the browser and either:
- Show the properties. The URL can be copied from the dialog that appears.
- View image. Copy the URL from the browser address bar.
Alternately:
- Use the browser 'show source' and copy it from the HTML.
- For those with enough rep. (100+, to edit a community Wiki answer), go to edit the answer and pull the URL from the text.
Code
Below is a Java class which splits up the chess piece sprite sheet, suitable for pasting in to an MCVE:
import java.awt.image.*;
import javax.imageio.*;
import java.net.*;
import java.io.*;
import java.util.*;
public final class ChessSprites {
private ChessSprites() {}
public static final int SIZE = 64;
public static final BufferedImage SHEET;
static {
try {
// see https://stackoverflow.com/a/19209651/2891664
SHEET = ImageIO.read(new URL("https://i.stack.imgur.com/memI0.png"));
} catch (IOException x) {
throw new UncheckedIOException(x);
}
}
public static final BufferedImage GOLD_QUEEN = SHEET.getSubimage(0 * SIZE, 0, SIZE, SIZE);
public static final BufferedImage SILVER_QUEEN = SHEET.getSubimage(0 * SIZE, SIZE, SIZE, SIZE);
public static final BufferedImage GOLD_KING = SHEET.getSubimage(1 * SIZE, 0, SIZE, SIZE);
public static final BufferedImage SILVER_KING = SHEET.getSubimage(1 * SIZE, SIZE, SIZE, SIZE);
public static final BufferedImage GOLD_ROOK = SHEET.getSubimage(2 * SIZE, 0, SIZE, SIZE);
public static final BufferedImage SILVER_ROOK = SHEET.getSubimage(2 * SIZE, SIZE, SIZE, SIZE);
public static final BufferedImage GOLD_KNIGHT = SHEET.getSubimage(3 * SIZE, 0, SIZE, SIZE);
public static final BufferedImage SILVER_KNIGHT = SHEET.getSubimage(3 * SIZE, SIZE, SIZE, SIZE);
public static final BufferedImage GOLD_BISHOP = SHEET.getSubimage(4 * SIZE, 0, SIZE, SIZE);
public static final BufferedImage SILVER_BISHOP = SHEET.getSubimage(4 * SIZE, SIZE, SIZE, SIZE);
public static final BufferedImage GOLD_PAWN = SHEET.getSubimage(5 * SIZE, 0, SIZE, SIZE);
public static final BufferedImage SILVER_PAWN = SHEET.getSubimage(5 * SIZE, SIZE, SIZE, SIZE);
public static final List<BufferedImage> SPRITES =
Collections.unmodifiableList(Arrays.asList(GOLD_QUEEN, SILVER_QUEEN,
GOLD_KING, SILVER_KING,
GOLD_ROOK, SILVER_ROOK,
GOLD_KNIGHT, SILVER_KNIGHT,
GOLD_BISHOP, SILVER_BISHOP,
GOLD_PAWN, SILVER_PAWN));
}
相关文章