예제 #1
0
            public static void Convert(PixelBox src, PixelBox dst, IPixelConverter pixelConverter)
            {
                {
                    var srcptr       = (BufferBase)src.Data.Clone();
                    var dstptr       = (BufferBase)dst.Data.Clone();
                    var srcSliceSkip = src.SliceSkip;
                    var dstSliceSkip = dst.SliceSkip;
                    var k            = src.Right - src.Left;

                    for (var z = src.Front; z < src.Back; z++)
                    {
                        for (var y = src.Top; y < src.Bottom; y++)
                        {
                            for (var x = 0; x < k; x++)
                            {
                                pixelConverter.Convert(srcptr, dstptr, x);
                            }
                            srcptr.Ptr += src.RowPitch * PixelUtil.GetNumElemBytes(src.Format);
                            dstptr.Ptr += dst.RowPitch * PixelUtil.GetNumElemBytes(dst.Format);
                        }
                        srcptr.Ptr += srcSliceSkip;
                        dstptr.Ptr += dstSliceSkip;
                    }
                }
            }
예제 #2
0
    public override ImageMap ConvertToImageMap(IPixelConverter pconv)
    {
        if (pconv == null)
        {
            pconv = new CanonicalPixelConverter();
        }

        ImageMap res = new ImageMap(Width, Height);

        // This code is quite slow, but I found no quick way to convert and
        // access the raw image data at always the same format. So, fix it or
        // stick with it. At least it looks elegant ;-)
        //获取图片的每一个像素
        for (int y = 0; y < Height; ++y)
        {
            for (int x = 0; x < Width; ++x)
            {
                Color col = bm.GetPixel(x, y);
                //每一个像素取正常化存入res[x,y]中
                res[x, y] = pconv.Convert(col.R, col.G, col.B);
            }
        }

        return(res);
    }
예제 #3
0
 public abstract ImageMap ConvertToImageMap(IPixelConverter pconv);
예제 #4
0
			public static void Convert( PixelBox src, PixelBox dst, IPixelConverter pixelConverter )
			{
				unsafe
				{
					byte* srcptr = (byte*)( src.Data.ToPointer() );
					byte* dstptr = (byte*)( dst.Data.ToPointer() );
					int srcSliceSkip = src.SliceSkip;
					int dstSliceSkip = dst.SliceSkip;
					int k = src.Right - src.Left;

					for ( int z = src.Front; z < src.Back; z++ )
					{
						for ( int y = src.Top; y < src.Bottom; y++ )
						{
							for ( int x = 0; x < k; x++ )
							{
								pixelConverter.Convert( srcptr, dstptr, x );
							}
							srcptr += src.RowPitch * PixelUtil.GetNumElemBytes( src.Format );
							dstptr += dst.RowPitch * PixelUtil.GetNumElemBytes( dst.Format );
						}
						srcptr += srcSliceSkip;
						dstptr += dstSliceSkip;
					}
				}
			}
예제 #5
0
 public ImageBuilder(IImageSampler sampler, IPixelConverter converter, Color transparencyColor)
 {
     _sampler = sampler;
     _converter = converter;
     _transparencyColor = transparencyColor;
 }
예제 #6
0
 public void Dispose()
 {
     if (_bmp != null)
     {
         _bmp.Dispose();
         _bmp = null;
         _frameDimension = null;
         _sampler = null;
         _converter = null;
     }
 }
예제 #7
0
            public ImageBufferBuilder(Bitmap bmp, Size size, IImageSampler sampler, IPixelConverter converter, Color transparencyColor)
            {
                _bmp = bmp;
                _size = size;
                _sampler = sampler;
                _converter = converter;
                _transparencyColor = transparencyColor;

                _frameDimension = new FrameDimension(bmp.FrameDimensionsList[0]);
                _frameCount = bmp.GetFrameCount(_frameDimension);
            }