Quantcast
Channel: 質問!ITmedia 新着質問(Java/253)
Viewing all articles
Browse latest Browse all 2439

BufferedImageを使った画像の読み書き

$
0
0
BufferedImageを使ってpng画像の読み書きをjavaでコーディングしています。 やりたい事は、ある画像Aを読み込んで、別ファイルBに全く同じに書き出すだけなのですが、どうしても同じファイルサイズにならなくて困っています。 RGBA値は同じなのですが、よく見るとほんの少し色が違ったりしています。 ご教授お願い致します。 java:1.6.0_65 --- 下記、実際のプログラムです--- public static void main(String[] args) { String file = "A.png"; BufferedImage bi = null; BufferedImage bi2 = null; try { bi = ImageIO.read(new File(file)); int ww = bi.getWidth(); int hh = bi.getHeight(); bi2 = new BufferedImage(ww, hh, bi.getType()); WritableRaster raster = bi2.getRaster(); for (int y=0; y>16&0xff, c>>8&0xff, c&0xff, c>>>24}; raster.setPixel(x, y, pixel); } } ImageIO.write(bi2, "png", new File("B.png")); } catch (IOException e) { e.printStackTrace(); } }

Viewing all articles
Browse latest Browse all 2439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>