Exemple #1
0
        /**
         * Readerとbufferを初期化する関数です。コンストラクタから呼び出します。
         * 継承クラスでこの関数を拡張することで、対応するバッファタイプの種類を増やせます。
         * @param i_size
         * ラスタのサイズ
         * @param i_raster_type
         * バッファタイプ
         * @param i_is_alloc
         * 外部参照/内部バッファのフラグ
         * @return
         * 初期化が成功すると、trueです。
         * @
         */
        protected virtual void initInstance(NyARIntSize i_size, int i_raster_type, bool i_is_alloc)
        {
            //バッファの構築
            switch (i_raster_type)
            {
            case NyARBufferType.INT1D_X8R8G8B8_32:
                this._buf = i_is_alloc ? new int[i_size.w * i_size.h] : null;
                break;

            case NyARBufferType.BYTE1D_B8G8R8X8_32:
            case NyARBufferType.BYTE1D_X8R8G8B8_32:
                this._buf = i_is_alloc ? new byte[i_size.w * i_size.h * 4] : null;
                break;

            case NyARBufferType.BYTE1D_R8G8B8_24:
            case NyARBufferType.BYTE1D_B8G8R8_24:
                this._buf = i_is_alloc ? new byte[i_size.w * i_size.h * 3] : null;
                break;

            case NyARBufferType.WORD1D_R5G6B5_16LE:
                this._buf = i_is_alloc ? new short[i_size.w * i_size.h] : null;
                break;

            default:
                throw new NyARException();
            }
            //readerの構築
            this._rgb_pixel_driver   = NyARRgbPixelDriverFactory.createDriver(this);
            this._is_attached_buffer = i_is_alloc;
            return;
        }
        /**
         * コンストラクタです。
         * @param i_width
         * このラスタの幅
         * @param i_height
         * このラスタの高さ
         * @
         */
        public NyARColorPatt_PseudoAffine(int i_width, int i_height)
        {
            this._size        = new NyARIntSize(i_width, i_height);
            this._patdata     = new int[i_height * i_width];
            this._pixelreader = NyARRgbPixelDriverFactory.createDriver(this);
            //疑似アフィン変換のパラメタマトリクスを計算します。
            //長方形から計算すると、有効要素がm00,m01,m02,m03,m10,m11,m20,m23,m30になります。
            NyARDoubleMatrix44 mat = this._invmat;

            mat.m00 = 0;
            mat.m01 = 0;
            mat.m02 = 0;
            mat.m03 = 1.0;
            mat.m10 = 0;
            mat.m11 = i_width - 1;
            mat.m12 = 0;
            mat.m13 = 1.0;
            mat.m20 = (i_width - 1) * (i_height - 1);
            mat.m21 = i_width - 1;
            mat.m22 = i_height - 1;
            mat.m23 = 1.0;
            mat.m30 = 0;
            mat.m31 = 0;
            mat.m32 = i_height - 1;
            mat.m33 = 1.0;
            mat.inverse(mat);
            return;
        }
 private void initInstance(int i_width, int i_height, int i_point_per_pix)
 {
     Debug.Assert(i_width > 2 && i_height > 2);
     this._sample_per_pixel = i_point_per_pix;
     this._size             = new NyARIntSize(i_width, i_height);
     this._patdata          = new int[i_height * i_width];
     this._pixelreader      = NyARRgbPixelDriverFactory.createDriver(this);
     return;
 }
 /**
  * コンストラクタです。
  * 解像度を指定して、インスタンスを生成します。
  * @param i_width
  * ラスタのサイズ
  * @param i_height
  * ラスタのサイズ
  * @
  */
 public NyARColorPatt_Base(int i_width, int i_height)
 {
     //入力制限
     Debug.Assert(i_width <= 64 && i_height <= 64);
     this._size        = new NyARIntSize(i_width, i_height);
     this._patdata     = new int[i_height * i_width];
     this._pixelreader = NyARRgbPixelDriverFactory.createDriver(this);
     return;
 }