OSDN Git Service

ac20221346530272fd818fc1230de242756f6108
[nyartoolkit-and/nyartoolkit-and.git] / trunk / src.utils / qt / jp / nyatla / nyartoolkit / qt / utils / QtNyARRaster_RGB.java
1 /* \r
2  * PROJECT: NyARToolkit Quicktime utilities.\r
3  * --------------------------------------------------------------------------------\r
4  * Copyright (C)2008 arc@dmz\r
5  *\r
6  * This program is free software; you can redistribute it and/or\r
7  * modify it under the terms of the GNU General Public License\r
8  * as published by the Free Software Foundation; either version 2\r
9  * of the License, or (at your option) any later version.\r
10  * \r
11  * This program is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  * \r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this framework; if not, write to the Free Software\r
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19  * \r
20  * For further information please contact.\r
21  *      \r
22  *      <arc(at)digitalmuseum.jp>\r
23  * \r
24  */\r
25 package jp.nyatla.nyartoolkit.qt.utils;\r
26 \r
27 \r
28 import jp.nyatla.nyartoolkit.NyARException;\r
29 import jp.nyatla.nyartoolkit.core.raster.*;\r
30 import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
31 import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
32 import jp.nyatla.nyartoolkit.core.types.*;\r
33 \r
34 /**\r
35  * RGB形式のbyte配列をラップするNyARRasterです。\r
36  * 保持したデータからBufferedImageを出力する機能も持ちます。\r
37  */\r
38 public class QtNyARRaster_RGB implements INyARRgbRaster\r
39 {\r
40         private NyARIntSize _size;\r
41         private byte[] _buffer;\r
42         private NyARRgbPixelReader_BYTE1D_R8G8B8_24 _reader;\r
43         private int _buffer_type;\r
44 \r
45         /**\r
46          * QuickTimeオブジェクトからイメージを取得するラスタオブジェクトを作ります。\r
47          * この\r
48          * @param i_width\r
49          * @param i_height\r
50          */\r
51         public QtNyARRaster_RGB(int i_width, int i_height)\r
52         {\r
53                 this._size=new NyARIntSize(i_width,i_height);\r
54                 this._buffer= null;\r
55                 this._buffer_type=NyARBufferType.BYTE1D_R8G8B8_24;\r
56                 this._reader = new NyARRgbPixelReader_BYTE1D_R8G8B8_24(null,this._size);\r
57         }\r
58         \r
59         final public int getWidth()\r
60         {\r
61                 return this._size.w;\r
62         }\r
63 \r
64         final public int getHeight()\r
65         {\r
66                 return this._size.h;\r
67         }\r
68 \r
69         final public NyARIntSize getSize()\r
70         {\r
71                 return this._size;\r
72         }\r
73         final public int getBufferType()\r
74         {\r
75                 return this._buffer_type;\r
76         }\r
77         final public INyARRgbPixelReader getRgbPixelReader()\r
78         {\r
79                 return this._reader;\r
80         }\r
81         final public boolean hasBuffer()\r
82         {\r
83                 return this._buffer!=null;\r
84         }\r
85         final public Object getBuffer()\r
86         {\r
87                 assert(this._buffer!=null);\r
88                 return this._buffer;\r
89         }\r
90         final public boolean isEqualBufferType(int i_type_value)\r
91         {\r
92                 return this._buffer_type==i_type_value;\r
93         }\r
94         final public void wrapBuffer(Object i_ref_buf) throws NyARException\r
95         {\r
96                 this._buffer=(byte[])i_ref_buf;\r
97                 this._reader.switchBuffer(i_ref_buf);\r
98         }\r
99         /**\r
100          *      @deprecated hasBuffer()関数を使ってください。\r
101          * \r
102          */\r
103         final public boolean hasData()\r
104         {\r
105                 return this.hasBuffer();\r
106         }\r
107 }\r