Jframe에서이 프로그램의 출력 (세 이미지)을 인쇄해야합니다 ... 코드가 아래에 있습니다 ... "test "넷빈즈의 폴더 만은 캔트j 프레임에서 이미지의 개별 RGB 구성 요소를 페인팅하는 방법
import javax.imageio.ImageIO;
import java.io.File;
import java.awt.image.BufferedImage;
public class RGBSpliter {
static BufferedImage image;
static BufferedImage redImage, greenImage, blueImage;
static final int TYPE = BufferedImage.TYPE_INT_ARGB;
public static void main(String[] args) throws Exception {
image = ImageIO.read(new File("F:\\Images\\animated\\008.jpg"));
int w = image.getWidth();
int h = image.getHeight();
redImage = new BufferedImage(w, h, TYPE);
greenImage = new BufferedImage(w, h, TYPE);
blueImage = new BufferedImage(w, h, TYPE);
for (int y = 0; y < h; y++)
for (int x = 0; x < w; x++) {
int pixel = image.getRGB(x, y);
int alpha_mask = pixel & 0xff000000;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;
redImage.setRGB(x, y, alpha_mask | (red << 16));
greenImage.setRGB(x, y, alpha_mask | (green << 8));
blueImage.setRGB(x, y, alpha_mask | blue);
}
String format = "png";
ImageIO.write(redImage, format, new File("image_red.png"));
ImageIO.write(greenImage, format, new File("image_green.png"));
ImageIO.write(blueImage, format, new File("image_blue.png"));
}
}
'frame.add (새 JLabel의 (새 이미지 아이콘 (redImage)))'...? – MadProgrammer
모든 비트 이동이 필요 이상으로 복잡하지는 않습니까? 'redImage.setRGB (x, y, pixel & 0xffff0000); greenImage.setRGB (x, y, 픽셀 및 0xff00ff00); blueImage.setRGB (x, y, 픽셀 및 0xff0000ff); ' –
@MadProgrammer_ 우리는 귀하의 코드를 시도했습니다. 그러나 그것은 작동하지 않았다. 이미지가 jFrame에 표시되지 않습니다. 제발, 당신의 도움이 시급합니다. – user3335751