예제 #1
0
        public bool update(INyARGrayscaleRaster i_raster, SquareStack.Item i_sq)
        {
            if (!this._id_pickup.pickFromRaster(i_raster.getGsPixelDriver(), i_sq.ob_vertex, this._id_patt, this._id_param))
            {
                return(false);
            }
            if (!this._id_encoder.encode(this._id_patt, this._id_data))
            {
                return(false);
            }
            //IDを検出
            long s = this._id_data.marker_id;

            for (int i = this.Count - 1; i >= 0; i--)
            {
                MarkerInfoNyId target = this[i];
                if (target.nyid_range_s > s || s > target.nyid_range_e)
                {
                    continue;
                }
                //既に認識済なら無視
                if (target.lost_count == 0)
                {
                    continue;
                }
                //一致したよー。
                target.nyid = s;
                target.dir  = this._id_param.direction;
                target.sq   = i_sq;
                return(true);
            }
            return(false);
        }
예제 #2
0
        public bool update(INyARGrayscaleRaster i_raster, SquareStack.Item i_sq)
        {
            if (!this._pickup.getARPlayCardId(i_raster.getGsPixelDriver(), i_sq.ob_vertex, this._id_param))
            {
                return(false);
            }
            //IDを検出
            int s = this._id_param.id;

            for (int i = this.Count - 1; i >= 0; i--)
            {
                Item target = this[i];
                if (target.nyid_range_s > s || s > target.nyid_range_e)
                {
                    continue;
                }
                //既に認識済なら無視
                if (target.lost_count == 0)
                {
                    continue;
                }
                //一致したよー。
                target.id  = s;
                target.dir = this._id_param.direction;
                target.sq  = i_sq;
                return(true);
            }
            return(false);
        }
        public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
        {
            NyARIntSize size            = this._ref_raster.getSize();
            int         bp              = (l + t * size.w);
            int         b               = t + h;
            int         row_padding_dst = (size.w - w);
            int         row_padding_src = row_padding_dst;
            int         pix_count       = w;
            int         pix_mod_part    = pix_count - (pix_count % 8);
            int         src_ptr         = t * size.w + l;

            int[] in_buf = (int[])this._ref_raster.getBuffer();
            switch (o_raster.getBufferType())
            {
            case NyARBufferType.INT1D_GRAY_8:
                int   v;
                int[] out_buf = (int[])o_raster.getBuffer();
                for (int y = t; y < b; y++)
                {
                    int x = 0;
                    for (x = pix_count - 1; x >= pix_mod_part; x--)
                    {
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) >> 2;
                    }
                    for (; x >= 0; x -= 8)
                    {
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                        v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                    }
                    bp      += row_padding_dst;
                    src_ptr += row_padding_src;
                }
                return;

            default:
                INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
                for (int y = t; y < b; y++)
                {
                    for (int x = 0; x < pix_count; x++)
                    {
                        v = in_buf[src_ptr++];
                        out_drv.setPixel(x, y, (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3);
                    }
                }
                return;
            }
        }
 public void doFilter(int[] i_tone_table, INyARGrayscaleRaster i_output)
 {
     INyARGsPixelDriver outd = i_output.getGsPixelDriver();
     INyARGsPixelDriver ind = this._raster.getGsPixelDriver();
     NyARIntSize s = this._raster.getSize();
     for (int y = s.h - 1; y >= 0; y--)
     {
         for (int x = s.w - 1; x >= 0; x--)
         {
             outd.setPixel(x, y, i_tone_table[ind.getPixel(x, y)]);
         }
     }
 }
예제 #5
0
        public void doFilter(INyARGrayscaleRaster i_output)
        {
            INyARGsPixelDriver ind  = this._raster.getGsPixelDriver();
            INyARGsPixelDriver outd = i_output.getGsPixelDriver();
            NyARIntSize        s    = this._raster.getSize();

            for (int y = s.h - 1; y >= 0; y--)
            {
                for (int x = s.w - 1; x >= 0; x--)
                {
                    outd.setPixel(x, y, 255 - ind.getPixel(x, y));
                }
            }
        }
        public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
        {
            int[] wk        = this._wk;
            int   b         = t + h;
            int   pix_count = w;

            switch (o_raster.getBufferType())
            {
            default:
                INyARGsPixelDriver  out_drv = o_raster.getGsPixelDriver();
                INyARRgbPixelDriver in_drv  = this._ref_raster.getRgbPixelDriver();
                for (int y = t; y < b; y++)
                {
                    for (int x = pix_count - 1; x >= 0; x--)
                    {
                        in_drv.getPixel(x, y, wk);
                        out_drv.setPixel(x, y, (306 * (wk[2] & 0xff) + 601 * (wk[1] & 0xff) + 117 * (wk[0] & 0xff)) >> 10);
                    }
                }
                return;
            }
        }
        public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
        {
            byte[] work = this._work;
            BitmapData bm = this._ref_raster.lockBitmap();
            NyARIntSize size = this._ref_raster.getSize();
            int bp = (l + t * size.w) * 4 + (int)bm.Scan0;
            int b = t + h;
            int row_padding_dst = (size.w - w);
            int row_padding_src = row_padding_dst * 4;
            int pix_count = w;
            int pix_mod_part = pix_count - (pix_count % 8);
            int dst_ptr = t * size.w + l;
            // in_buf = (byte[])this._ref_raster.getBuffer();
            switch (o_raster.getBufferType())
            {
                case NyARBufferType.INT1D_GRAY_8:
                    int[] out_buf = (int[])o_raster.getBuffer();
                    for (int y = t; y < b; y++)
                    {

                        int x = 0;
                        for (x = pix_count - 1; x >= pix_mod_part; x--)
                        {
                            int p = Marshal.ReadInt32((IntPtr)bp);
                            out_buf[dst_ptr++] = (((p >> 16) & 0xff) + ((p >> 8) & 0xff) + (p & 0xff)) / 3;
                            bp += 4;
                        }
                        for (; x >= 0; x -= 8)
                        {
                            Marshal.Copy((IntPtr)bp, work, 0, 32);
                            out_buf[dst_ptr++] = (work[0] + work[1] + work[2]) / 3;
                            out_buf[dst_ptr++] = (work[4] + work[5] + work[6]) / 3;
                            out_buf[dst_ptr++] = (work[8] + work[9] + work[10]) / 3;
                            out_buf[dst_ptr++] = (work[12] + work[13] + work[14]) / 3;
                            out_buf[dst_ptr++] = (work[16] + work[17] + work[18]) / 3;
                            out_buf[dst_ptr++] = (work[20] + work[21] + work[22]) / 3;
                            out_buf[dst_ptr++] = (work[24] + work[25] + work[26]) / 3;
                            out_buf[dst_ptr++] = (work[28] + work[29] + work[30]) / 3;
                            bp += 32;
                        }
                        bp += row_padding_src;
                        dst_ptr += row_padding_dst;
                    }
                    this._ref_raster.unlockBitmap();
                    return;
                default:
                    INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
                    for (int y = t; y < b; y++)
                    {
                        for (int x = 0; x < pix_count; x++)
                        {
                            int p = Marshal.ReadInt32((IntPtr)bp);
                            out_drv.setPixel(x, y, (((p >> 16) & 0xff) + ((p >> 8) & 0xff) + (p & 0xff)) / 3);
                            bp += 4;
                        }
                        bp += row_padding_src;
                    }
                    this._ref_raster.unlockBitmap();
                    return;
            }
        }
예제 #8
0
        public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
        {
			Color32[] c=(Color32[])(this._ref_raster.getBuffer());
            NyARIntSize size = this._ref_raster.getSize();
            int src = (l + t * size.w) * 4;
            int b = t + h;
            int row_padding_dst = (size.w - w);
            int row_padding_src = row_padding_dst * 4;
            int pix_count = w;
            int pix_mod_part = pix_count - (pix_count % 8);
            
            // in_buf = (byte[])this._ref_raster.getBuffer();
            switch (o_raster.getBufferType())
            {
                case NyARBufferType.INT1D_GRAY_8:
                    int[] out_buf = (int[])o_raster.getBuffer();
					int dst_ptr;
					if(this._is_inverse){
						dst_ptr=(h-1-t) * size.w + l;
						row_padding_dst-=size.w*2;
					}else{
						dst_ptr=t * size.w + l;
					}
                    for (int y = t; y < b; y++)
                    {						
                        int x = 0;
						Color32 p;
                        for (x = pix_count - 1; x >= pix_mod_part; x--)
                        {
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
                        }
                        for (; x >= 0; x -= 8)
                        {
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
							p=c[src++];
                            out_buf[dst_ptr++] = (p.r+p.g+p.b) / 3;
                        }
						dst_ptr+=row_padding_dst;
                        src += row_padding_src;
                    }
                    return;
                default:
                    INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
                    for (int y = t; y < b; y++)
                    {
                        for (int x = 0; x < pix_count; x++)
                        {
                            Color32 p = c[src++];
                            out_drv.setPixel(x, y,(p.r+p.g+p.b) / 3);
                        }
                        src += row_padding_src;
                    }
                    return;
            }

        }
예제 #9
0
 public NyARRlePixelDriver_GSReader(INyARGrayscaleRaster i_raster)
 {
     this._ref_driver = i_raster.getGsPixelDriver();
 }
예제 #10
0
        public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
        {
            Color32[]   c               = (Color32[])(this._ref_raster.getBuffer());
            NyARIntSize size            = this._ref_raster.getSize();
            int         src             = (l + t * size.w) * 4;
            int         b               = t + h;
            int         row_padding_dst = (size.w - w);
            int         row_padding_src = row_padding_dst * 4;
            int         pix_count       = w;
            int         pix_mod_part    = pix_count - (pix_count % 8);

            // in_buf = (byte[])this._ref_raster.getBuffer();
            switch (o_raster.getBufferType())
            {
            case NyARBufferType.INT1D_GRAY_8:
                int[] out_buf = (int[])o_raster.getBuffer();
                int   dst_ptr;
                if (this._is_inverse)
                {
                    dst_ptr          = (h - 1 - t) * size.w + l;
                    row_padding_dst -= size.w * 2;
                }
                else
                {
                    dst_ptr = t * size.w + l;
                }
                for (int y = t; y < b; y++)
                {
                    int     x = 0;
                    Color32 p;
                    for (x = pix_count - 1; x >= pix_mod_part; x--)
                    {
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                    }
                    for (; x >= 0; x -= 8)
                    {
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                        p = c[src++];
                        out_buf[dst_ptr++] = (p.r + p.g + p.b) / 3;
                    }
                    dst_ptr += row_padding_dst;
                    src     += row_padding_src;
                }
                return;

            default:
                INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
                for (int y = t; y < b; y++)
                {
                    for (int x = 0; x < pix_count; x++)
                    {
                        Color32 p = c[src++];
                        out_drv.setPixel(x, y, (p.r + p.g + p.b) / 3);
                    }
                    src += row_padding_src;
                }
                return;
            }
        }
 public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
 {
     int[] wk = this._wk;
     int b = t + h;
     int pix_count = w;
     switch (o_raster.getBufferType())
     {
         default:
             INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
             INyARRgbPixelDriver in_drv = this._ref_raster.getRgbPixelDriver();
             for (int y = t; y < b; y++)
             {
                 for (int x = pix_count - 1; x >= 0; x--)
                 {
                     in_drv.getPixel(x, y, wk);
                     out_drv.setPixel(x, y, (306 * (wk[2] & 0xff) + 601 * (wk[1] & 0xff) + 117 * (wk[0] & 0xff)) >> 10);
                 }
             }
             return;
     }
 }
 public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
 {
     NyARIntSize size = this._ref_raster.getSize();
     int bp = (l + t * size.w);
     int b = t + h;
     int row_padding_dst = (size.w - w);
     int row_padding_src = row_padding_dst;
     int pix_count = w;
     int pix_mod_part = pix_count - (pix_count % 8);
     int src_ptr = t * size.w + l;
     int[] in_buf = (int[])this._ref_raster.getBuffer();
     switch (o_raster.getBufferType())
     {
         case NyARBufferType.INT1D_GRAY_8:
             int v;
             int[] out_buf = (int[])o_raster.getBuffer();
             for (int y = t; y < b; y++)
             {
                 int x = 0;
                 for (x = pix_count - 1; x >= pix_mod_part; x--)
                 {
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) >> 2;
                 }
                 for (; x >= 0; x -= 8)
                 {
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                     v = in_buf[src_ptr++]; out_buf[bp++] = (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3;
                 }
                 bp += row_padding_dst;
                 src_ptr += row_padding_src;
             }
             return;
         default:
             INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
             for (int y = t; y < b; y++)
             {
                 for (int x = 0; x < pix_count; x++)
                 {
                     v = in_buf[src_ptr++];
                     out_drv.setPixel(x, y, (((v >> 16) & 0xff) + ((v >> 8) & 0xff) + (v & 0xff)) / 3);
                 }
             }
             return;
     }
 }
예제 #13
0
        public void convertRect(int l, int t, int w, int h, INyARGrayscaleRaster o_raster)
        {
            byte[]      work            = this._work;
            BitmapData  bm              = this._ref_raster.lockBitmap();
            NyARIntSize size            = this._ref_raster.getSize();
            int         bp              = (l + t * size.w) * 4 + (int)bm.Scan0;
            int         b               = t + h;
            int         row_padding_dst = (size.w - w);
            int         row_padding_src = row_padding_dst * 4;
            int         pix_count       = w;
            int         pix_mod_part    = pix_count - (pix_count % 8);
            int         dst_ptr         = t * size.w + l;

            // in_buf = (byte[])this._ref_raster.getBuffer();
            switch (o_raster.getBufferType())
            {
            case NyARBufferType.INT1D_GRAY_8:
                int[] out_buf = (int[])o_raster.getBuffer();
                for (int y = t; y < b; y++)
                {
                    int x = 0;
                    for (x = pix_count - 1; x >= pix_mod_part; x--)
                    {
                        int p = Marshal.ReadInt32((IntPtr)bp);
                        out_buf[dst_ptr++] = (((p >> 16) & 0xff) + ((p >> 8) & 0xff) + (p & 0xff)) / 3;
                        bp += 4;
                    }
                    for (; x >= 0; x -= 8)
                    {
                        Marshal.Copy((IntPtr)bp, work, 0, 32);
                        out_buf[dst_ptr++] = (work[0] + work[1] + work[2]) / 3;
                        out_buf[dst_ptr++] = (work[4] + work[5] + work[6]) / 3;
                        out_buf[dst_ptr++] = (work[8] + work[9] + work[10]) / 3;
                        out_buf[dst_ptr++] = (work[12] + work[13] + work[14]) / 3;
                        out_buf[dst_ptr++] = (work[16] + work[17] + work[18]) / 3;
                        out_buf[dst_ptr++] = (work[20] + work[21] + work[22]) / 3;
                        out_buf[dst_ptr++] = (work[24] + work[25] + work[26]) / 3;
                        out_buf[dst_ptr++] = (work[28] + work[29] + work[30]) / 3;
                        bp += 32;
                    }
                    bp      += row_padding_src;
                    dst_ptr += row_padding_dst;
                }
                this._ref_raster.unlockBitmap();
                return;

            default:
                INyARGsPixelDriver out_drv = o_raster.getGsPixelDriver();
                for (int y = t; y < b; y++)
                {
                    for (int x = 0; x < pix_count; x++)
                    {
                        int p = Marshal.ReadInt32((IntPtr)bp);
                        out_drv.setPixel(x, y, (((p >> 16) & 0xff) + ((p >> 8) & 0xff) + (p & 0xff)) / 3);
                        bp += 4;
                    }
                    bp += row_padding_src;
                }
                this._ref_raster.unlockBitmap();
                return;
            }
        }