public NyARRgb2GsFilterArtkTh_BYTE1D_C8C8C8_24(INyARRgbRaster i_raster)
 {
     Debug.Assert(
             i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8_24) ||
             i_raster.isEqualBufferType(NyARBufferType.BYTE1D_R8G8B8_24));
     this._raster = i_raster;
 }
 public NyARRgb2GsFilterArtkTh_BYTE1D_C8C8C8_24(INyARRgbRaster i_raster)
 {
     Debug.Assert(
         i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8_24) ||
         i_raster.isEqualBufferType(NyARBufferType.BYTE1D_R8G8B8_24));
     this._raster = i_raster;
 }
 public void multiPixel(int pk_l, int pk_t, double[] cpara, int i_resolution, INyARRgbRaster i_in_raster, INyARRgbRaster o_out)
 {
     Debug.Assert(i_in_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));
     //出力形式による分岐(分解能が高い時は大した差が出ないから、ANYだけ。)
     multiPixel_ANY(pk_l, pk_t, i_in_raster.getWidth(), i_in_raster.getHeight(), i_resolution, cpara, (byte[])i_in_raster.getBuffer(), o_out);
     return;
 }
        public void onePixel(int pk_l, int pk_t, double[] cpara, INyARRgbRaster i_in_raster, INyARRgbRaster o_out)
        {
            Debug.Assert(i_in_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));
            //出力形式による分岐
            switch (o_out.getBufferType())
            {
            case NyARBufferType.INT1D_X8R8G8B8_32:
                onePixel_INT1D_X8R8G8B8_32(pk_l, pk_t, i_in_raster.getWidth(), i_in_raster.getHeight(), cpara, (byte[])i_in_raster.getBuffer(), o_out);
                break;

            default:
                onePixel_ANY(pk_l, pk_t, i_in_raster.getWidth(), i_in_raster.getHeight(), cpara, (byte[])i_in_raster.getBuffer(), o_out);
                break;
            }
            return;
        }
Exemple #5
0
        /* DsXRGB32Rasterの内容を保持しているサーフェイスにコピーします。
         */
        public void CopyFromXRGB32(INyARRgbRaster i_sample)
        {
            Debug.Assert(i_sample.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));
            int            pitch;
            GraphicsStream gs       = this.m_surface.LockRectangle(LockFlags.None, out pitch);
            int            s_stride = this.m_width * 4;

            if (pitch % s_stride == 0)
            {
                Marshal.Copy((byte[])i_sample.getBuffer(), 0, (IntPtr)((int)gs.InternalData), this.m_width * 4 * this.m_height);
            }
            else
            {
                int s_idx = 0;
                int d_idx = (int)gs.InternalData;
                for (int i = this.m_height - 1; i >= 0; i--)
                {
                    //どう考えてもポインタです。
                    Marshal.Copy((byte[])i_sample.getBuffer(), s_idx, (IntPtr)(d_idx), s_stride);
                    s_idx += s_stride;
                    d_idx += pitch;
                }
            }



            /*
             * int cp_size = this.m_width * 4;
             * int s_idx=0;
             * int d_idx = (this.m_height - 1) * cp_size;
             * for(int i=this.m_height-1;i>=0;i--){
             *  //どう考えてもポインタです。
             *  Marshal.Copy((byte[])i_sample.getBufferReader().getBuffer(),s_idx,(IntPtr)((int)gs.InternalData+d_idx),cp_size);
             *  s_idx += cp_size;
             *  d_idx -= cp_size;
             * }
             *
             */

            this.m_surface.UnlockRectangle();

            return;
        }
 public NyARRgb2GsFilterArtkTh_WORD1D_R5G6B5_16LE(INyARRgbRaster i_raster)
 {
     Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.WORD1D_R5G6B5_16LE));
     this._raster = i_raster;
 }
 public NyARRgb2GsFilterArtkTh_INT1D_X8R8G8B8_32(INyARRgbRaster i_raster)
 {
     Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));
     this._raster = i_raster;
 }
 public NyARRgb2GsFilterArtkTh_BYTE1D_B8G8R8X8_32(INyARRgbRaster i_raster)
 {
     Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));
     this._raster = i_raster;
 }
 public NyARRgb2GsFilterArtkTh_WORD1D_R5G6B5_16LE(INyARRgbRaster i_raster)
 {
     Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.WORD1D_R5G6B5_16LE));
     this._raster = i_raster;
 }
 public NyARRgb2GsFilterArtkTh_INT1D_X8R8G8B8_32(INyARRgbRaster i_raster)
 {
     Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));
     this._raster = i_raster;
 }
 public NyARRgb2GsFilterArtkTh_BYTE1D_B8G8R8X8_32(INyARRgbRaster i_raster)
 {
     Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));
     this._raster = i_raster;
 }
        private void onePixel_INT1D_X8R8G8B8_32(int pk_l, int pk_t, int in_w, int in_h, double[] cpara, INyARRgbPixelReader i_in_reader, INyARRgbRaster o_out)
        {
            Debug.Assert(o_out.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));
            int[] rgb_tmp  = this.__pickFromRaster_rgb_tmp;
            int[] pat_data = (int[])o_out.getBuffer();

            //ピクセルリーダーを取得
            double cp0 = cpara[0];
            double cp3 = cpara[3];
            double cp6 = cpara[6];
            double cp1 = cpara[1];
            double cp4 = cpara[4];
            double cp7 = cpara[7];

            int    out_w      = o_out.getWidth();
            int    out_h      = o_out.getHeight();
            double cp7_cy_1   = cp7 * pk_t + 1.0 + cp6 * pk_l;
            double cp1_cy_cp2 = cp1 * pk_t + cpara[2] + cp0 * pk_l;
            double cp4_cy_cp5 = cp4 * pk_t + cpara[5] + cp3 * pk_l;
            int    p          = 0;

            for (int iy = out_h - 1; iy >= 0; iy--)
            {
                //解像度分の点を取る。
                double cp7_cy_1_cp6_cx   = cp7_cy_1;
                double cp1_cy_cp2_cp0_cx = cp1_cy_cp2;
                double cp4_cy_cp5_cp3_cx = cp4_cy_cp5;

                for (int ix = out_w - 1; ix >= 0; ix--)
                {
                    //1ピクセルを作成
                    double d = 1 / (cp7_cy_1_cp6_cx);
                    int    x = (int)((cp1_cy_cp2_cp0_cx) * d);
                    int    y = (int)((cp4_cy_cp5_cp3_cx) * d);
                    if (x < 0)
                    {
                        x = 0;
                    }
                    else if (x >= in_w)
                    {
                        x = in_w - 1;
                    }
                    if (y < 0)
                    {
                        y = 0;
                    }
                    else if (y >= in_h)
                    {
                        y = in_h - 1;
                    }

                    i_in_reader.getPixel(x, y, rgb_tmp);
                    cp7_cy_1_cp6_cx   += cp6;
                    cp1_cy_cp2_cp0_cx += cp0;
                    cp4_cy_cp5_cp3_cx += cp3;

                    pat_data[p] = (rgb_tmp[0] << 16) | (rgb_tmp[1] << 8) | ((rgb_tmp[2] & 0xff));
                    p++;
                }
                cp7_cy_1   += cp7;
                cp1_cy_cp2 += cp1;
                cp4_cy_cp5 += cp4;
            }
            return;
        }
        private void onePixel_INT1D_X8R8G8B8_32(int pk_l, int pk_t, int in_w, int in_h, double[] cpara, byte[] i_in_buf, INyARRgbRaster o_out)
        {
            Debug.Assert(o_out.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));
            int[] pat_data = (int[])o_out.getBuffer();
            //ピクセルリーダーを取得
            double cp0 = cpara[0];
            double cp3 = cpara[3];
            double cp6 = cpara[6];
            double cp1 = cpara[1];
            double cp4 = cpara[4];
            double cp7 = cpara[7];

            int    out_w = o_out.getWidth();
            int    out_h = o_out.getHeight();
            double cp7_cy_1 = cp7 * pk_t + 1.0 + cp6 * pk_l;
            double cp1_cy_cp2 = cp1 * pk_t + cpara[2] + cp0 * pk_l;
            double cp4_cy_cp5 = cp4 * pk_t + cpara[5] + cp3 * pk_l;
            int    r, g, b;
            int    p = 0;

            for (int iy = 0; iy < out_h; iy++)
            {
                //解像度分の点を取る。
                double cp7_cy_1_cp6_cx   = cp7_cy_1;
                double cp1_cy_cp2_cp0_cx = cp1_cy_cp2;
                double cp4_cy_cp5_cp3_cx = cp4_cy_cp5;

                for (int ix = 0; ix < out_w; ix++)
                {
                    //1ピクセルを作成
                    double d = 1 / (cp7_cy_1_cp6_cx);
                    int    x = (int)((cp1_cy_cp2_cp0_cx) * d);
                    int    y = (int)((cp4_cy_cp5_cp3_cx) * d);
                    if (x < 0)
                    {
                        x = 0;
                    }
                    else if (x >= in_w)
                    {
                        x = in_w - 1;
                    }
                    if (y < 0)
                    {
                        y = 0;
                    }
                    else if (y >= in_h)
                    {
                        y = in_h - 1;
                    }

                    int bp = (x + y * in_w) * 4;
                    r = (i_in_buf[bp + 2] & 0xff);
                    g = (i_in_buf[bp + 1] & 0xff);
                    b = (i_in_buf[bp + 0] & 0xff);
                    cp7_cy_1_cp6_cx   += cp6;
                    cp1_cy_cp2_cp0_cx += cp0;
                    cp4_cy_cp5_cp3_cx += cp3;
                    pat_data[p]        = (r << 16) | (g << 8) | ((b & 0xff));
                    p++;
                }
                cp7_cy_1   += cp7;
                cp1_cy_cp2 += cp1;
                cp4_cy_cp5 += cp4;
            }
            return;
        }
        private void multiPixel_INT1D_X8R8G8B8_32(int pk_l, int pk_t, int in_w, int in_h, int i_resolution, double[] cpara, INyARRgbPixelReader i_in_reader, INyARRgbRaster o_out)
        {
            Debug.Assert(o_out.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));
            int res_pix = i_resolution * i_resolution;

            int[] rgb_tmp  = this.__pickFromRaster_rgb_tmp;
            int[] pat_data = (int[])o_out.getBuffer();

            //ピクセルリーダーを取得
            double cp0 = cpara[0];
            double cp3 = cpara[3];
            double cp6 = cpara[6];
            double cp1 = cpara[1];
            double cp4 = cpara[4];
            double cp7 = cpara[7];
            double cp2 = cpara[2];
            double cp5 = cpara[5];

            int out_w = o_out.getWidth();
            int out_h = o_out.getHeight();
            int p     = (out_w * out_h - 1);

            for (int iy = out_h - 1; iy >= 0; iy--)
            {
                //解像度分の点を取る。
                for (int ix = out_w - 1; ix >= 0; ix--)
                {
                    int r, g, b;
                    r = g = b = 0;
                    int    cy = pk_t + iy * i_resolution;
                    int    cx = pk_l + ix * i_resolution;
                    double cp7_cy_1_cp6_cx_b   = cp7 * cy + 1.0 + cp6 * cx;
                    double cp1_cy_cp2_cp0_cx_b = cp1 * cy + cp2 + cp0 * cx;
                    double cp4_cy_cp5_cp3_cx_b = cp4 * cy + cp5 + cp3 * cx;
                    for (int i2y = i_resolution - 1; i2y >= 0; i2y--)
                    {
                        double cp7_cy_1_cp6_cx   = cp7_cy_1_cp6_cx_b;
                        double cp1_cy_cp2_cp0_cx = cp1_cy_cp2_cp0_cx_b;
                        double cp4_cy_cp5_cp3_cx = cp4_cy_cp5_cp3_cx_b;
                        for (int i2x = i_resolution - 1; i2x >= 0; i2x--)
                        {
                            //1ピクセルを作成
                            double d = 1 / (cp7_cy_1_cp6_cx);
                            int    x = (int)((cp1_cy_cp2_cp0_cx) * d);
                            int    y = (int)((cp4_cy_cp5_cp3_cx) * d);
                            if (x < 0)
                            {
                                x = 0;
                            }
                            else if (x >= in_w)
                            {
                                x = in_w - 1;
                            }
                            if (y < 0)
                            {
                                y = 0;
                            }
                            else if (y >= in_h)
                            {
                                y = in_h - 1;
                            }

                            i_in_reader.getPixel(x, y, rgb_tmp);
                            r += rgb_tmp[0];
                            g += rgb_tmp[1];
                            b += rgb_tmp[2];
                            cp7_cy_1_cp6_cx   += cp6;
                            cp1_cy_cp2_cp0_cx += cp0;
                            cp4_cy_cp5_cp3_cx += cp3;
                        }
                        cp7_cy_1_cp6_cx_b   += cp7;
                        cp1_cy_cp2_cp0_cx_b += cp1;
                        cp4_cy_cp5_cp3_cx_b += cp4;
                    }
                    r          /= res_pix;
                    g          /= res_pix;
                    b          /= res_pix;
                    pat_data[p] = ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff));
                    p--;
                }
            }
            return;
        }