상속: PixelFarm.Drawing.Image
예제 #1
0
        public void Fill(ActualImage img, int x, int y)
        {
            var imgReadWrite = new MyImageReaderWriter();

            imgReadWrite.ReloadImage(img);
            Fill(imgReadWrite, x, y);
        }
 public MyMiniAggCanvasRenderElement(RootGraphic rootgfx, int width, int height)
     : base(rootgfx, width, height)
 {
     this.actualImage = new ActualImage(width, height, PixelFarm.Agg.PixelFormat.ARGB32);
     this.gfx2d = Graphics2D.CreateFromImage(actualImage);
     needUpdate = true;
 }
예제 #3
0
        public static int[] CopyImgBuffer(ActualImage img, int width)
        {
            //calculate stride for the width

            int destStride = ActualImage.CalculateStride(width, PixelFormat.ARGB32);
            int h          = img.Height;
            int newBmpW    = destStride / 4;

            int[] buff2 = new int[newBmpW * img.Height];
            unsafe
            {
                TempMemPtr srcBufferPtr = ActualImage.GetBufferPtr(img);
                byte *     srcBuffer    = (byte *)srcBufferPtr.Ptr;
                int        srcIndex     = 0;
                int        srcStride    = img.Stride;
                fixed(int *destHead = &buff2[0])
                {
                    byte *destHead2 = (byte *)destHead;

                    for (int line = 0; line < h; ++line)
                    {
                        //System.Runtime.InteropServices.Marshal.Copy(srcBuffer, srcIndex, (IntPtr)destHead2, destStride);
                        NaitveMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride);
                        srcIndex  += srcStride;
                        destHead2 += destStride;
                    }
                }

                srcBufferPtr.Release();
            }
            return(buff2);
        }
예제 #4
0
 /// <summary>
 /// copy from actual image direct to hBmpScan0
 /// </summary>
 /// <param name="actualImage"></param>
 /// <param name="hBmpScan0"></param>
 public static void CopyToWindowsBitmapSameSize(
    ActualImage actualImage,
    IntPtr hBmpScan0)
 {
     //1st, fast
     byte[] rawBuffer = ActualImage.GetBuffer(actualImage);
     System.Runtime.InteropServices.Marshal.Copy(rawBuffer, 0,
        hBmpScan0, rawBuffer.Length);
 }
        unsafe internal static void CopyGlyphBitmap(FontGlyph fontGlyph)
        {
            FT_Bitmap* ftBmp = (FT_Bitmap*)fontGlyph.glyphMatrix.bitmap;
            //image is 8 bits grayscale
            int h = ftBmp->rows;
            int w = ftBmp->width;
            int stride = ftBmp->pitch;
            int size = stride * h;
            //copy it to array  
            //bmp glyph is bottom up 
            //so .. invert it...

            byte[] buff = new byte[size];
            //------------------------------------------------
            byte* currentSrc = ftBmp->buffer;
            int srcpos = size;
            int targetpos = 0;
            for (int r = 1; r <= h; ++r)
            {
                srcpos -= stride;
                currentSrc = ftBmp->buffer + srcpos;
                for (int c = 0; c < stride; ++c)
                {
                    buff[targetpos] = *(currentSrc + c);
                    targetpos++;
                }
            }

            ////------------------------------------------------
            //IntPtr bmpPtr = (IntPtr)ftBmp->buffer;
            //Marshal.Copy((IntPtr)ftBmp->buffer, buff, 0, size);
            ////------------------------------------------------ 

            //------------------------------------------------
            fontGlyph.glyImgBuffer8 = buff;
            //convert to 32bpp
            //make gray value as alpha channel color value
            ActualImage actualImage = new ActualImage(w, h, Agg.PixelFormat.ARGB32);
            byte[] newBmp32Buffer = ActualImage.GetBuffer(actualImage);
            int src_p = 0;
            int target_p = 0;
            for (int r = 0; r < h; ++r)
            {
                for (int c = 0; c < w; ++c)
                {
                    byte srcColor = buff[src_p + c];
                    //expand to 4 channel
                    newBmp32Buffer[target_p] = 0;
                    newBmp32Buffer[target_p + 1] = 0;
                    newBmp32Buffer[target_p + 2] = 0;
                    newBmp32Buffer[target_p + 3] = srcColor; //A
                    target_p += 4;
                }
                src_p += stride;
            }
            fontGlyph.glyphImage32 = actualImage;
        }
        public MiniAggCanvasRenderElement(RootGraphic rootgfx, int width, int height)
            : base(rootgfx, width, height)
        {

            this.actualImage = new ActualImage(width, height, PixelFarm.Agg.PixelFormat.ARGB32);
            this.gfx2d = Graphics2D.CreateFromImage(actualImage);
            this.painter = new AggCanvasPainter((ImageGraphics2D)gfx2d);
            needUpdate = true;
            this.BackColor = Color.White;
        }
예제 #7
0
        public static int[] GetBuffer2(ActualImage img)
        {
            int[] buff2 = new int[img.width * img.height];
            unsafe
            {
                fixed(byte *header = &img.pixelBuffer[0])
                {
                    System.Runtime.InteropServices.Marshal.Copy((IntPtr)header, buff2, 0, buff2.Length);
                }
            }

            return(buff2);
        }
예제 #8
0
 public ImageGraphics2D(ActualImage destImage)
 {
     //create from actual image
     this.destActualImage       = destImage;
     this.destImageReaderWriter = new MyImageReaderWriter(destImage);
     this.sclineRas             = new ScanlineRasterizer();
     this.sclineRasToBmp        = new ScanlineRasToDestBitmapRenderer();
     this.destWidth             = destImage.Width;
     this.destHeight            = destImage.Height;
     this.clipBox = new RectInt(0, 0, destImage.Width, destImage.Height);
     this.sclineRas.SetClipBox(this.clipBox);
     this.sclinePack8    = new ScanlinePacked8();
     this.currentBlender = this.pixBlenderRGBA32 = new PixelBlenderBGRA();
 }
예제 #9
0
        private void button1_Click(object sender, EventArgs e)
        {

            if (g == null)
            {
                destImg = new ActualImage(400, 300, PixelFarm.Agg.Image.PixelFormat.ARGB32);
                imgGfx2d = new ImageGraphics2D(destImg, null); //no platform
                p = new AggCanvasPainter(imgGfx2d);
                winBmp = new Bitmap(400, 300, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                g = this.CreateGraphics();
            }
            //  ReadAndRender(@"..\..\segoeui.ttf");
            ReadAndRender(@"..\..\tahoma.ttf");
            //ReadAndRender(@"..\..\CompositeMS.ttf");
        }
예제 #10
0
        public static int[] CopyImgBuffer(ActualImage img)
        {
            int[] buff2 = new int[img.Width * img.Height];
            unsafe
            {
                //byte[] pixelBuffer = ActualImage.GetBuffer(img);
                TempMemPtr pixBuffer = ActualImage.GetBufferPtr(img);
                //fixed (byte* header = &pixelBuffer[0])
                byte *header = (byte *)pixBuffer.Ptr;
                {
                    System.Runtime.InteropServices.Marshal.Copy((IntPtr)header, buff2, 0, buff2.Length);//length in bytes
                }
                pixBuffer.Release();
            }

            return(buff2);
        }
예제 #11
0
        public ImageGraphics2D(ActualImage destImage)
        {
            //create from actual image
            this.destImage = destImage;

            this.destActualImage = destImage;
            this.destImageReaderWriter = new MyImageReaderWriter();
            destImageReaderWriter.ReloadImage(destImage);
            this.sclineRas = new ScanlineRasterizer();
            this.sclineRasToBmp = new ScanlineRasToDestBitmapRenderer();
            this.destWidth = destImage.Width;
            this.destHeight = destImage.Height;
            this.clipBox = new RectInt(0, 0, destImage.Width, destImage.Height);
            this.sclineRas.SetClipBox(this.clipBox);
            this.sclinePack8 = new ScanlinePacked8();
            this.currentBlender = this.pixBlenderRGBA32 = new PixelBlenderBGRA();
        }
예제 #12
0
        public static ActualImage CreateFromBuffer(int width, int height, PixelFormat format, byte[] buffer)
        {
            if (format != PixelFormat.ARGB32)
            {
                throw new NotSupportedException();
            }
            //
            var img = new ActualImage(width, height, format);

            unsafe
            {
                fixed(byte *header = &img.pixelBuffer[0])
                {
                    System.Runtime.InteropServices.Marshal.Copy(buffer, 0, (IntPtr)header, buffer.Length);
                }
            }
            return(img);
        }
예제 #13
0
        public override void DrawImage(Image img, double left, double top)
        {
            ActualImage actualImg = img as ActualImage;

            if (actualImg == null)
            {
                //? TODO
                return;
            }
            //check image caching system
            if (this._renderQuality == RenderQualtity.Fast)
            {
                //DrawingBuffer.RectD destRect = new DrawingBuffer.RectD(left, top, img.Width, img.Height);
                //DrawingBuffer.RectD srcRect = new DrawingBuffer.RectD(0, 0, img.Width, img.Height);
                BitmapBuffer srcBmp = new BitmapBuffer(img.Width, img.Height, ActualImage.GetBuffer(actualImg));
                this._bxt.CopyBlit(left, top, srcBmp);
                return;
            }

            this.sharedImageWriterReader.ReloadImage(actualImg);

            //save, restore later...
            bool useSubPix = UseSubPixelLcdEffect;

            //before render an image we turn off vxs subpixel rendering
            this.UseSubPixelLcdEffect   = false;
            _aggsx.UseSubPixelRendering = false;

            if (this._orientation == DrawBoardOrientation.LeftTop)
            {
                //place left upper corner at specific x y
                this._aggsx.Render(this.sharedImageWriterReader, left, this.Height - (top + img.Height));
            }
            else
            {
                //left-bottom as original
                //place left-lower of the img at specific (x,y)
                this._aggsx.Render(this.sharedImageWriterReader, left, top);
            }

            //restore...
            this.UseSubPixelLcdEffect   = useSubPix;
            _aggsx.UseSubPixelRendering = useSubPix;
        }
예제 #14
0
        public override void DrawImage(Image img, params Transform.AffinePlan[] affinePlans)
        {
            ActualImage actualImg = img as ActualImage;

            if (actualImg == null)
            {
                //? TODO
                return;
            }

            //if (this._renderQuality == RenderQualtity.Fast)
            //{
            //    //todo, review here again
            //    BitmapBuffer srcBmp = new BitmapBuffer(img.Width, img.Height, ActualImage.GetBuffer(actualImg));
            //    //this._bxt.CopyBlit(left, top, srcBmp);
            //    DrawingBuffer.MatrixTransform mx = new MatrixTransform(new DrawingBuffer.AffinePlan[]{
            //        DrawingBuffer.AffinePlan.Translate(-img.Width/2,-img.Height/2),
            //        DrawingBuffer.AffinePlan.Rotate(AggMath.deg2rad(-70))
            //        //DrawingBuffer.AffinePlan.Translate(100,100)
            //    });
            //    //DrawingBuffer.MatrixTransform mx = new MatrixTransform(DrawingBuffer.Affine.IdentityMatrix);
            //    this._bxt.BlitRender(srcBmp, false, 1, mx);
            //    return;
            //}


            this.sharedImageWriterReader.ReloadImage((ActualImage)img);

            bool useSubPix = UseSubPixelLcdEffect; //save, restore later...

            //before render an image we turn off vxs subpixel rendering
            this.UseSubPixelLcdEffect   = false;
            _aggsx.UseSubPixelRendering = false;


            this._aggsx.Render(sharedImageWriterReader, affinePlans);



            //restore...
            this.UseSubPixelLcdEffect   = useSubPix;
            _aggsx.UseSubPixelRendering = useSubPix;
        }
        public void ReloadImage(ActualImage actualImage)
        {
            if (this.actualImage == actualImage)
            {
                return;
            }
            this.actualImage = actualImage;
            //calculate image stride
            switch (actualImage.PixelFormat)
            {
            case PixelFormat.ARGB32:
            {
                Attach(actualImage.Width,
                       actualImage.Height,
                       actualImage.BitDepth,
                       ActualImage.GetBuffer(actualImage),
                       pixelBlenderRGBA ?? (pixelBlenderRGBA = new PixelBlenderBGRA()));
                //Attach(actualImage.Width,
                //    actualImage.Height,
                //    actualImage.BitDepth,
                //    ActualImage.GetBuffer(actualImage),
                //    pixelBlenderRGBA ?? (pixelBlenderRGBA = new PixelBlenderGammaBGRA(0.8f)));
            }
            break;

            case PixelFormat.GrayScale8:
            {
                Attach(actualImage.Width,
                       actualImage.Height,
                       actualImage.BitDepth,
                       ActualImage.GetBuffer(actualImage),
                       pixelBlenderGray ?? (pixelBlenderGray = new PixelBlenderGray(1)));
            }
            break;

            case PixelFormat.RGB24:
            default:
            {
                throw new NotSupportedException();
            }
            }
        }
        /// <summary>
        /// load image to the reader/writer
        /// </summary>
        /// <param name="actualImage"></param>
        public void ReloadImage(ActualImage actualImage)
        {
            if (this.actualImage == actualImage)
            {
                return;
            }

            //in this version we support actual images
            //in 2 formats :
            //1. 32 bits ARGB
            //2. 8  bits gray scale
            //

            this.actualImage = actualImage;
            switch (actualImage.PixelFormat)
            {
            case PixelFormat.ARGB32:
            {
                Attach(actualImage.Width,
                       actualImage.Height,
                       actualImage.BitDepth,
                       ActualImage.GetBuffer(actualImage),
                       pixelBlenderRGBA ?? (pixelBlenderRGBA = new PixelBlenderBGRA()));
            }
            break;

            case PixelFormat.GrayScale8:
            {
                Attach(actualImage.Width,
                       actualImage.Height,
                       actualImage.BitDepth,
                       ActualImage.GetBuffer(actualImage),
                       pixelBlenderGray ?? (pixelBlenderGray = new PixelBlenderGray(1)));
            }
            break;

            default:
            {
                throw new NotSupportedException();
            }
            }
        }
        public void ReloadImage(ActualImage actualImage)
        {
            if (this.actualImage == actualImage)
            {
                return;
            }
            this.actualImage = actualImage;
            //calculate image stride
            switch (actualImage.PixelFormat)
            {
            case PixelFormat.Rgba32:
            {
                Attach(actualImage.Width,
                       actualImage.Height,
                       actualImage.BitDepth,
                       actualImage.GetBuffer(),
                       new PixelBlenderBGRA());
            }
            break;

            case PixelFormat.GrayScale8:
            {
                Attach(actualImage.Width,
                       actualImage.Height,
                       actualImage.BitDepth,
                       actualImage.GetBuffer(),
                       new PixelFarm.Agg.Image.PixelBlenderGray(1));
            }
            break;

            case PixelFormat.Rgb24:
            default:
            {
                throw new NotSupportedException();
            }
            }
        }
예제 #18
0
        public static int[] CopyImgBuffer(ActualImage src, int srcX, int srcY, int srcW, int srcH)
        {
            //calculate stride for the width
            int destStride = ActualImage.CalculateStride(srcW, PixelFormat.ARGB32);
            int newBmpW    = destStride / 4;

            int[] buff2 = new int[newBmpW * srcH];
            unsafe
            {
                TempMemPtr srcBufferPtr = ActualImage.GetBufferPtr(src);
                byte *     srcBuffer    = (byte *)srcBufferPtr.Ptr;
                int        srcIndex     = 0;
                int        srcStride    = src.Stride;
                fixed(int *destHead = &buff2[0])
                {
                    byte *destHead2 = (byte *)destHead;

                    //move to specific src line
                    srcIndex += srcStride * srcY;

                    int lineEnd = srcY + srcH;

                    for (int line = srcY; line < lineEnd; ++line)
                    {
                        //System.Runtime.InteropServices.Marshal.Copy(srcBuffer, srcIndex, (IntPtr)destHead2, destStride);
                        NaitveMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride);
                        srcIndex  += srcStride;
                        destHead2 += destStride;
                    }
                }

                srcBufferPtr.Release();
            }

            return(buff2);
        }
예제 #19
0
 public void Fill(ActualImage img, int x, int y)
 {
     var imgReadWrite = new MyImageReaderWriter();
     imgReadWrite.ReloadImage(img);
     Fill(imgReadWrite, x, y);
 }
예제 #20
0
 public void Fill(ActualImage img, int x, int y)
 {
     Fill(new MyImageReaderWriter(img), x, y);
 }
 public override void ReplaceBuffer(int[] newbuffer)
 {
     ActualImage.ReplaceBuffer(actualImage, newbuffer);
 }
예제 #22
0
 public override void DrawImage(ActualImage actualImage, double x, double y)
 {
     this.sharedImageWriterReader.ReloadImage(actualImage);
     this.gx.Render(this.sharedImageWriterReader, x, y);
 }
예제 #23
0
 public override void DrawImage(ActualImage actualImage, params AffinePlan[] affinePlans)
 {
     //create gl bmp
     GLBitmap glBmp = new GLBitmap(actualImage.Width, actualImage.Height, ActualImage.GetBuffer(actualImage), false);
     _canvas.DrawImage(glBmp, 0, 0);
     glBmp.Dispose();
 }
예제 #24
0
        public void ReloadImage(ActualImage actualImage)
        {
            if (this.actualImage == actualImage)
            {
                return;
            }
            this.actualImage = actualImage;
            //calculate image stride
            switch (actualImage.PixelFormat)
            {
                case PixelFormat.ARGB32:
                    {

                        Attach(actualImage.Width,
                            actualImage.Height,
                            actualImage.BitDepth,
                            ActualImage.GetBuffer(actualImage),
                            pixelBlenderRGBA ?? (pixelBlenderRGBA = new PixelBlenderBGRA()));
                    }
                    break;
                case PixelFormat.GrayScale8:
                    {
                        Attach(actualImage.Width,
                          actualImage.Height,
                          actualImage.BitDepth,
                          ActualImage.GetBuffer(actualImage),
                          pixelBlenderGray ?? (pixelBlenderGray = new PixelBlenderGray(1)));
                    }
                    break;
                case PixelFormat.RGB24:
                default:
                    {
                        throw new NotSupportedException();
                    }
            }
        }
예제 #25
0
        //-------------------------------------------------------



        public abstract void DrawImage(ActualImage actualImage, double x, double y);
예제 #26
0
 public void DrawImage(ActualImage actualImage, double x, double y)
 {
     this.sharedImageWriterReader.ReloadImage(actualImage);
     this.gx.Render(this.sharedImageWriterReader, x, y);
 }
예제 #27
0
 public abstract void DrawImage(ActualImage actualImage, params Transform.AffinePlan[] affinePlans); 
예제 #28
0
 public static byte[] GetBuffer(ActualImage img)
 {
     return img.pixelBuffer;
    
 }
예제 #29
0
        /////////////////////////////////////////////////////////////////////////////////////

        public static void CopyToGdiPlusBitmapSameSize(
            ActualImage actualImage,
            SkiaSharp.SKBitmap skBmp)
        {
            //agg store image buffer head-down
            //when copy to window bmp we here to flip 
            //style1: copy row by row *** (fastest)***
            {
                //System.GC.Collect();
                //System.Diagnostics.Stopwatch sss = new System.Diagnostics.Stopwatch();
                //sss.Start();
                //for (int i = 0; i < 1000; ++i)
                //{
                int h = skBmp.Height;
                int w = skBmp.Width;
                

                //BitmapData bitmapData1 = bitmap.LockBits(
                //          new Rectangle(0, 0,
                //              w,
                //              h),
                //              System.Drawing.Imaging.ImageLockMode.ReadWrite,
                //              bitmap.PixelFormat); 
                skBmp.LockPixels();
                IntPtr scan0 = skBmp.GetPixels();
                int stride = actualImage.Stride;
                byte[] srcBuffer = ActualImage.GetBuffer(actualImage);
                unsafe
                {
                    fixed (byte* bufferH = &srcBuffer[0])
                    {
                        byte* target = (byte*)scan0;
                        int startRowAt = ((h - 1) * stride);
                        for (int y = h; y > 0; --y)
                        {
                            //byte* src = bufferH + ((y - 1) * stride);
                            System.Runtime.InteropServices.Marshal.Copy(
                               srcBuffer,//src
                               startRowAt,
                               (IntPtr)target,
                               stride);
                            startRowAt -= stride;
                            target += stride;
                        }
                    }
                }
                skBmp.UnlockPixels();
                //}
                //sss.Stop();
                //long ms = sss.ElapsedMilliseconds;
            }
            //-----------------------------------
            //style2: copy all, then flip again
            //{
            //    System.GC.Collect();
            //    System.Diagnostics.Stopwatch sss = new System.Diagnostics.Stopwatch();
            //    sss.Start();
            //    for (int i = 0; i < 1000; ++i)
            //    {
            //        byte[] rawBuffer = ActualImage.GetBuffer(actualImage);
            //        var bmpdata = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
            //          System.Drawing.Imaging.ImageLockMode.ReadOnly,
            //         bitmap.PixelFormat);


            //        System.Runtime.InteropServices.Marshal.Copy(rawBuffer, 0,
            //            bmpdata.Scan0, rawBuffer.Length);

            //        bitmap.UnlockBits(bmpdata);
            //        bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
            //    }

            //    sss.Stop();
            //    long ms = sss.ElapsedMilliseconds; 
            //}
            //-----------------------------------

            //-----------------------------------
            //style3: copy row by row + 
            //{
            //    System.GC.Collect();
            //    System.Diagnostics.Stopwatch sss = new System.Diagnostics.Stopwatch();
            //    sss.Start();
            //    for (int i = 0; i < 1000; ++i)
            //    {
            //        int h = bitmap.Height;
            //        int w = bitmap.Width;
            //        BitmapData bitmapData1 = bitmap.LockBits(
            //                  new Rectangle(0, 0,
            //                      w,
            //                      h),
            //                      System.Drawing.Imaging.ImageLockMode.ReadWrite,
            //                      bitmap.PixelFormat);
            //        IntPtr scan0 = bitmapData1.Scan0;
            //        int stride = bitmapData1.Stride;
            //        byte[] buffer = ActualImage.GetBuffer(actualImage);
            //        unsafe
            //        {
            //            fixed (byte* bufferH = &buffer[0])
            //            {
            //                byte* target = (byte*)scan0;
            //                for (int y = h; y > 0; --y)
            //                {
            //                    byte* src = bufferH + ((y - 1) * stride);
            //                    for (int n = stride - 1; n >= 0; --n)
            //                    {
            //                        *target = *src;
            //                        target++;
            //                        src++;
            //                    }
            //                }
            //            }
            //        }
            //        bitmap.UnlockBits(bitmapData1);
            //    }
            //    sss.Stop();
            //    long ms = sss.ElapsedMilliseconds;
            //} 
        }
예제 #30
0
        public static TempMemPtr GetBufferPtr(ActualImage img)
        {
            TempMemPtr tmp = new TempMemPtr(img.pixelBuffer);

            return(tmp);
        }
예제 #31
0
        ////----------------
        //MyBitmapData lockingBmp;
        //public override BitmapData LockBits()
        //{
        //    return this.lockingBmp = new Agg.ActualImage.MyBitmapData(pixelBuffer);
        //}
        //public override void UnlockBits(BitmapData bmpdata)
        //{
        //    if (bmpdata == lockingBmp)
        //    {
        //        this.lockingBmp.Dispose();
        //        lockingBmp = null;
        //    }
        //    else
        //    {
        //        throw new System.NotSupportedException();
        //    }
        //}
        //----------------

        public static byte[] GetBuffer(ActualImage img)
        {
            return(img.pixelBuffer);
        }
예제 #32
0
 public static void ReplaceBuffer(ActualImage img, int[] pixelBuffer)
 {
     img.pixelBuffer = pixelBuffer;
 }
예제 #33
0
 public override void DrawImage(ActualImage actualImage, double x, double y)
 {
     GLBitmap glBmp = new GLBitmap(actualImage.Width, actualImage.Height, ActualImage.GetBuffer(actualImage), false);
     _canvas.DrawImage(glBmp, (float)x, (float)y);
     glBmp.Dispose();
 }
예제 #34
0
        //-------------------------------------------------------


       

        public abstract void DrawImage(ActualImage actualImage, double x, double y);
예제 #35
0
 //================
 public static ImageGraphics2D CreateFromImage(ActualImage actualImage)
 {
     return(new ImageGraphics2D(actualImage));
 }
예제 #36
0
 public override void DrawImage(ActualImage actualImage, params Transform.AffinePlan[] affinePlans)
 {
     this.sharedImageWriterReader.ReloadImage(actualImage);
     this.gx.Render(sharedImageWriterReader, affinePlans);
 }
 public MyImageReaderWriter(ActualImage actualImage)
 {
     ReloadImage(actualImage);
 }
예제 #38
0
        public override void DrawImage(ActualImage actualImage, double x, double y)
        {
            //create Gdi bitmap from actual image
            int w = actualImage.Width;
            int h = actualImage.Height;
            switch (actualImage.PixelFormat)
            {
                case Agg.PixelFormat.ARGB32:
                    {

                        using (SKBitmap newBmp = new SKBitmap(actualImage.Width, actualImage.Height))
                        {
                            newBmp.LockPixels();
                            byte[] actualImgBuffer = ActualImage.GetBuffer(actualImage);
                            System.Runtime.InteropServices.Marshal.Copy(
                            actualImgBuffer,
                            0,
                            newBmp.GetPixels(),
                             actualImgBuffer.Length);
                            newBmp.UnlockPixels();
                        }
                        //newBmp.internalBmp.LockPixels();
                        //byte[] actualImgBuffer = ActualImage.GetBuffer(actualImage);

                        //System.Runtime.InteropServices.Marshal.Copy(
                        //     actualImgBuffer,
                        //     0,
                        //      newBmp.internalBmp.GetPixels(),
                        //      actualImgBuffer.Length);

                        //newBmp.internalBmp.UnlockPixels();
                        //return newBmp;

                        //copy data from acutal buffer to internal representation bitmap
                        //using (MySkBmp bmp = MySkBmp.CopyFrom(actualImage))
                        //{
                        //    _skCanvas.DrawBitmap(bmp.internalBmp, (float)x, (float)y);
                        //}
                    }
                    break;
                case Agg.PixelFormat.RGB24:
                    {
                    }
                    break;
                case Agg.PixelFormat.GrayScale8:
                    {
                    }
                    break;
                default:
                    throw new NotSupportedException();
            }
        }
예제 #39
0
 //================
 public static ImageGraphics2D CreateFromImage(ActualImage actualImage)
 {
     return new ImageGraphics2D(actualImage);
 }
예제 #40
0
 public override void DrawImage(ActualImage actualImage, params AffinePlan[] affinePlans)
 {
     //1. create special graphics 
     using (System.Drawing.Bitmap srcBmp = CreateBmpBRGA(actualImage))
     {
         var bmp = _bmpStore.GetFreeBmp();
         using (var g2 = System.Drawing.Graphics.FromImage(bmp))
         {
             //we can use recycle tmpVxsStore
             Affine destRectTransform = Affine.NewMatix(affinePlans);
             double x0 = 0, y0 = 0, x1 = bmp.Width, y1 = bmp.Height;
             destRectTransform.Transform(ref x0, ref y0);
             destRectTransform.Transform(ref x0, ref y1);
             destRectTransform.Transform(ref x1, ref y1);
             destRectTransform.Transform(ref x1, ref y0);
             var matrix = new System.Drawing.Drawing2D.Matrix(
                (float)destRectTransform.m11, (float)destRectTransform.m12,
                (float)destRectTransform.m21, (float)destRectTransform.m22,
                (float)destRectTransform.dx, (float)destRectTransform.dy);
             g2.Clear(System.Drawing.Color.Transparent);
             g2.Transform = matrix;
             //------------------------
             g2.DrawImage(srcBmp, new System.Drawing.PointF(0, 0));
             this._gfx.DrawImage(bmp, new System.Drawing.Point(0, 0));
         }
         _bmpStore.RelaseBmp(bmp);
     }
 }
예제 #41
0
 public void DrawImage(ActualImage actualImage, params Transform.AffinePlan[] affinePlans)
 {
     this.sharedImageWriterReader.ReloadImage(actualImage);
     this.gx.Render(sharedImageWriterReader, affinePlans);
 }
예제 #42
0
 static System.Drawing.Bitmap CreateBmpBRGA(ActualImage actualImage)
 {
     int w = actualImage.Width;
     int h = actualImage.Height;
     //copy data to bitmap
     //bgra  
     var bmp = new System.Drawing.Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     byte[] acutalBuffer = ActualImage.GetBuffer(actualImage);
     var bmpData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, w, h), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat);
     System.Runtime.InteropServices.Marshal.Copy(acutalBuffer, 0, bmpData.Scan0, acutalBuffer.Length);
     bmp.UnlockBits(bmpData);
     return bmp;
 }
예제 #43
0
 public abstract void DrawImage(ActualImage actualImage, params Transform.AffinePlan[] affinePlans);
예제 #44
0
 public override void DrawImage(ActualImage actualImage, double x, double y)
 {
     //create Gdi bitmap from actual image
     int w = actualImage.Width;
     int h = actualImage.Height;
     switch (actualImage.PixelFormat)
     {
         case Agg.PixelFormat.ARGB32:
             {
                 //copy data from acutal buffer to internal representation bitmap
                 using (var bmp = CreateBmpBRGA(actualImage))
                 {
                     this._gfx.DrawImageUnscaled(bmp, new System.Drawing.Point((int)x, (int)y));
                 }
             }
             break;
         case Agg.PixelFormat.RGB24:
             {
             }
             break;
         case Agg.PixelFormat.GrayScale8:
             {
             }
             break;
         default:
             throw new NotSupportedException();
     }
 }