protected override bool multiPixel(int pk_l, int pk_t, double[] cpara, int i_resolution, INyARRaster o_out) { BitmapData in_bmp = this._ref_raster.lockBitmap(); int in_w = this._ref_raster.getWidth(); int in_h = this._ref_raster.getHeight(); int res_pix = i_resolution * i_resolution; //ピクセルリーダーを取得 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(); if (o_out is NyARBitmapRaster) { NyARBitmapRaster bmr = ((NyARBitmapRaster)o_out); BitmapData bm = bmr.lockBitmap(); 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; } int px = Marshal.ReadInt32(in_bmp.Scan0, (x * 4 + y * in_bmp.Stride)); r += (px >> 16) & 0xff; // R g += (px >> 8) & 0xff; // G b += (px) & 0xff; // B 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; } Marshal.WriteInt32(bm.Scan0, ix * 4 + iy * bm.Stride, (0x00ff0000 & ((r / res_pix) << 16)) | (0x0000ff00 & ((g / res_pix) << 8)) | (0x0000ff & (b / res_pix))); } } bmr.unlockBitmap(); this._ref_raster.unlockBitmap(); return(true); } else if (o_out is INyARRgbRaster) { INyARRgbRaster out_raster = ((INyARRgbRaster)o_out); 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; } int px = Marshal.ReadInt32(in_bmp.Scan0, (x * 4 + y * in_bmp.Stride)); r += (px >> 16) & 0xff; // R g += (px >> 8) & 0xff; // G b += (px) & 0xff; // B 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; } out_raster.setPixel(ix, iy, r / res_pix, g / res_pix, b / res_pix); } } this._ref_raster.unlockBitmap(); return(true); } else { throw new NyARRuntimeException(); } }
public PerspectiveCopy_CSBitmap(NyARBitmapRaster i_ref_raster) { Debug.Assert(i_ref_raster.isEqualBufferType(NyARBufferType.OBJECT_CS_Bitmap)); this._ref_raster = i_ref_raster; }
protected override bool onePixel(int pk_l, int pk_t, double[] cpara, INyARRaster o_out) { BitmapData in_bmp = this._ref_raster.lockBitmap(); int in_w = this._ref_raster.getWidth(); int in_h = this._ref_raster.getHeight(); //ピクセルリーダーを取得 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, p; switch (o_out.getBufferType()) { case NyARBufferType.INT1D_X8R8G8B8_32: int[] pat_data = (int[])o_out.getBuffer(); 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; } // pat_data[p] = Marshal.ReadInt32(in_bmp.Scan0, (x * 4 + y * in_bmp.Stride)); //r = (px >> 16) & 0xff;// R //g = (px >> 8) & 0xff; // G //b = (px) & 0xff; // B 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)); //pat_data[p] = px; p++; } cp7_cy_1 += cp7; cp1_cy_cp2 += cp1; cp4_cy_cp5 += cp4; } this._ref_raster.unlockBitmap(); return(true); default: if (o_out is NyARBitmapRaster) { NyARBitmapRaster bmr = (NyARBitmapRaster)o_out; BitmapData bm = bmr.lockBitmap(); 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 pix = Marshal.ReadInt32(in_bmp.Scan0, (x * 4 + y * in_bmp.Stride)); Marshal.WriteInt32(bm.Scan0, ix * 4 + iy * bm.Stride, pix); cp7_cy_1_cp6_cx += cp6; cp1_cy_cp2_cp0_cx += cp0; cp4_cy_cp5_cp3_cx += cp3; p++; } cp7_cy_1 += cp7; cp1_cy_cp2 += cp1; cp4_cy_cp5 += cp4; } bmr.unlockBitmap(); this._ref_raster.unlockBitmap(); return(true); } else if (o_out is INyARRgbRaster) { //ANY to RGBx INyARRgbRaster out_raster = ((INyARRgbRaster)o_out); 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 px = Marshal.ReadInt32(in_bmp.Scan0, (x * 4 + y * in_bmp.Stride)); r = (px >> 16) & 0xff; // R g = (px >> 8) & 0xff; // G b = (px) & 0xff; // B cp7_cy_1_cp6_cx += cp6; cp1_cy_cp2_cp0_cx += cp0; cp4_cy_cp5_cp3_cx += cp3; out_raster.setPixel(ix, iy, r, g, b); } cp7_cy_1 += cp7; cp1_cy_cp2 += cp1; cp4_cy_cp5 += cp4; } this._ref_raster.unlockBitmap(); return(true); } break; } this._ref_raster.unlockBitmap(); return(false); }
public NyARRgb2GsFilterArtkTh_CsBitmap(NyARBitmapRaster i_raster) { Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.OBJECT_CS_Bitmap)); this._raster = i_raster; }