2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java edition ARToolKit class library.
\r
11 * Copyright (C)2008-2009 Ryo Iizuka
\r
13 * This program is free software: you can redistribute it and/or modify
\r
14 * it under the terms of the GNU General Public License as published by
\r
15 * the Free Software Foundation, either version 3 of the License, or
\r
16 * (at your option) any later version.
\r
18 * This program is distributed in the hope that it will be useful,
\r
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
21 * GNU General Public License for more details.
\r
23 * You should have received a copy of the GNU General Public License
\r
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
26 * For further information please contact.
\r
27 * http://nyatla.jp/nyatoolkit/
\r
28 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
31 package jp.nyatla.utils.j2se;
\r
33 import java.awt.image.*;
\r
34 import jp.nyatla.nyartoolkit.*;
\r
35 import jp.nyatla.nyartoolkit.core.raster.rgb.*;
\r
36 import jp.nyatla.nyartoolkit.core.raster.*;
\r
37 import jp.nyatla.nyartoolkit.core.rasterreader.*;
\r
39 public class NyARRasterImageIO
\r
42 * i_inの内容を、このイメージにコピーします。
\r
44 * @throws NyARException
\r
46 public static void copy(INyARRgbRaster i_in,BufferedImage o_out) throws NyARException
\r
48 assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight());
\r
51 INyARRgbPixelReader reader=i_in.getRgbPixelReader();
\r
52 int[] rgb=new int[3];
\r
54 for(int y=o_out.getHeight()-1;y>=0;y--){
\r
55 for(int x=o_out.getWidth()-1;x>=0;x--){
\r
56 reader.getPixel(x,y,rgb);
\r
57 o_out.setRGB(x,y,(rgb[0]<<16)|(rgb[1]<<8)|rgb[2]);
\r
65 * @throws NyARException
\r
67 public static void copy(INyARRaster i_in,BufferedImage o_out) throws NyARException
\r
69 assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight());
\r
70 if(i_in.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8))
\r
72 final int[] buf=(int[])i_in.getBufferReader().getBuffer();
\r
73 final int w=o_out.getWidth();
\r
74 final int h=o_out.getHeight();
\r
75 for(int y=h-1;y>=0;y--){
\r
76 for(int x=w-1;x>=0;x--){
\r
77 o_out.setRGB(x, y,buf[x+y*w]==0?0:0xffffff);
\r
84 * i_outへこのイメージを出力します。
\r
87 * @throws NyARException
\r
89 public static void copy(BufferedImage i_in,INyARRgbRaster o_out) throws NyARException
\r
91 assert o_out.getSize().isEqualSize(i_in.getWidth(), i_in.getHeight());
\r
94 INyARRgbPixelReader reader=o_out.getRgbPixelReader();
\r
95 int[] rgb=new int[3];
\r
96 for(int y=i_in.getHeight()-1;y>=0;y--){
\r
97 for(int x=i_in.getWidth()-1;x>=0;x--){
\r
98 int pix=i_in.getRGB(x, y);
\r
99 rgb[0]=(pix>>16)&0xff;
\r
100 rgb[1]=(pix>>8)&0xff;
\r
102 reader.setPixel(x,y,rgb);
\r
110 * @throws NyARException
\r
112 public static void copy(BufferedImage i_in,INyARRaster o_out) throws NyARException
\r
114 assert o_out.getSize().isEqualSize(i_in.getWidth(), i_in.getHeight());
\r
115 if(o_out.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8))
\r
117 final int[] buf=(int[])o_out.getBufferReader().getBuffer();
\r
118 final int w=i_in.getWidth();
\r
119 final int h=i_in.getHeight();
\r
120 for(int y=h-1;y>=0;y--){
\r
121 for(int x=w-1;x>=0;x--){
\r
122 buf[x+y*w]=(i_in.getRGB(x, y)&0xffffff)>0?1:0;
\r