--- /dev/null
+package jp.nyatla.nyartoolkit.core;\r
+\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+/**\r
+ * \r
+ * @author nyatla\r
+ * モノクロ256段階ラスタデータ保持クラス\r
+ */\r
+public class NyMono256Raster\r
+{\r
+ private NyARRaster _related_raster;\r
+ private int[][] _pixcels;\r
+ private int[] _average;\r
+ private int _width;\r
+ private int _height;\r
+ public void NyMono256Raster(int i_width,int i_height)\r
+ {\r
+ this._pixcels=new int[i_height][];\r
+ this._height=i_height;\r
+ this._width=i_width;\r
+\r
+ }\r
+ /**\r
+ * 連携するラスタオブジェクトを指定する。\r
+ * @param i_raster\r
+ */\r
+ public void SetRelatedRaster(NyARRaster i_raster)\r
+ {\r
+ //新しいラスタをセット\r
+ this._related_raster=i_raster;\r
+ //キャッシュしている情報を無効化\r
+ this._pixcels=new int[this._height][];\r
+ this._average=new int[this._height];\r
+ }\r
+ \r
+ public int[] GetLine(int i_line_no)\r
+ {\r
+ int[] line=this._pixcels[i_line_no];\r
+ if(line==null){\r
+ //ラインを作る。\r
+ line=new int[this._width];\r
+ this._related_raster.getPixelTotalRowLine(i_line_no,line);\r
+ this._pixcels[i_line_no]=line;\r
+ //平均値の計算\r
+ int ave=0;\r
+ for(int i=this._width-1;i>=0;i++){\r
+ ave+=line[i];\r
+ }\r
+ this._average[i_line_no]=ave/this._width;\r
+ }\r
+ return line;\r
+ }\r
+ public int GetLineAverage(int i_line_no)\r
+ {\r
+ if(this._pixcels[i_line_no]==null){\r
+ this.GetLine(i_line_no);\r
+ }\r
+ return this._average[i_line_no];\r
+ }\r
+ \r
+}\r