Java SWT Image 图像 —— 变灰、变亮变黑、旋转、反色、拉伸、透明叠加
图像变灰
private static ImageData rotate(ImageData srcData) { int bytesPerPixel = srcData.bytesPerLine / srcData.width; int destBytesPerLine = srcData.height * bytesPerPixel; byte[] newData = new byte[srcData.data.length]; int width = 0, height = 0; for (int srcY = 0; srcY < srcData.height; srcY++) { for (int srcX = 0; srcX < srcData.width; srcX++) { int destX = 0, destY = 0, destIndex = 0, srcIndex = 0; destX = srcY; destY = srcData.width - srcX - 1; width = srcData.height; height = srcData.width; destIndex = (destY * destBytesPerLine) + (destX * bytesPerPixel); srcIndex = (srcY * srcData.bytesPerLine) + (srcX * bytesPerPixel); System.arraycopy(srcData.data, srcIndex, newData, destIndex, bytesPerPixel); } } return new ImageData(width, height, srcData.depth, srcData.palette, destBytesPerLine, newData);}
?
?