* HITLab, University of Washington, Seattle\r
* http://www.hitl.washington.edu/artoolkit/\r
*\r
- * The NyARToolkit is Java version ARToolkit class library.\r
- * Copyright (C)2008 R.Iizuka\r
+ * The NyARToolkit is Java edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
*\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
* \r
* This program is distributed in the hope that it will be useful,\r
* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
* GNU General Public License for more details.\r
- * \r
+ *\r
* You should have received a copy of the GNU General Public License\r
- * along with this framework; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
* \r
* For further information please contact.\r
* http://nyatla.jp/nyatoolkit/\r
- * <airmail(at)ebony.plala.or.jp>\r
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
* \r
*/\r
package jp.nyatla.nyartoolkit.core.raster;\r
\r
+import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
public final class NyARGrayscaleRaster extends NyARRaster_BasicClass\r
{\r
\r
- protected int[] _ref_buf;\r
- private INyARBufferReader _buffer_reader;\r
- \r
- public NyARGrayscaleRaster(int i_width, int i_height)\r
+ protected Object _buf;\r
+ protected INyARBufferReader _buffer_reader;\r
+ public NyARGrayscaleRaster(int i_width, int i_height) throws NyARException\r
+ {\r
+ super(new NyARIntSize(i_width,i_height));\r
+ if(!initInstance(this._size,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8)){\r
+ throw new NyARException();\r
+ }\r
+ } \r
+ public NyARGrayscaleRaster(int i_width, int i_height,int i_raster_type) throws NyARException\r
{\r
super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = new int[i_height*i_width];\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8);\r
+ if(!initInstance(this._size,i_raster_type)){\r
+ throw new NyARException();\r
+ }\r
}\r
public INyARBufferReader getBufferReader()\r
{\r
return this._buffer_reader;\r
}\r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
+ {\r
+ switch(i_buf_type)\r
+ {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ this._buf = new int[i_size.w*i_size.h];\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ this._buffer_reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ return true;\r
+ }\r
}\r