public static int[] CopyImgBuffer(ActualBitmap img, int width) { //calculate stride for the width int destStride = ActualBitmap.CalculateStride(width, CpuBlit.Imaging.PixelFormat.ARGB32); int h = img.Height; int newBmpW = destStride / 4; int[] buff2 = new int[newBmpW * img.Height]; unsafe { CpuBlit.Imaging.TempMemPtr srcBufferPtr = ActualBitmap.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); NativeMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride); srcIndex += srcStride; destHead2 += destStride; } } srcBufferPtr.Release(); } return(buff2); }
public override void DrawImage(Image img, params AffinePlan[] affinePlans) { ActualBitmap actualImg = img as ActualBitmap; if (actualImg == null) { //? TODO return; } if (this._renderQuality == RenderQualtity.Fast) { //todo, review here again BitmapBuffer srcBmp = new BitmapBuffer(img.Width, img.Height, ActualBitmap.GetBuffer(actualImg)); if (affinePlans != null) { this._bxt.BlitRender(srcBmp, false, 1, new BitmapBufferEx.MatrixTransform(affinePlans)); } else { this._bxt.BlitRender(srcBmp, false, 1, null); } return; } 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(actualImg, affinePlans); //restore... this.UseSubPixelLcdEffect = useSubPix; _aggsx.UseSubPixelRendering = useSubPix; }
public MyBitmapBlender(ActualBitmap actualImage, PixelProcessing.PixelBlender32 pxBlender) { this.actualImage = actualImage; Attach(actualImage.Width, actualImage.Height, actualImage.BitDepth, ActualBitmap.GetBuffer(actualImage), pxBlender); //set default px blender }
public static ActualBitmap CreateFromBuffer(int width, int height, int[] buffer) { // var img = new ActualBitmap(width, height); unsafe { fixed(int *header = &img.pixelBuffer[0]) { System.Runtime.InteropServices.Marshal.Copy(buffer, 0, (IntPtr)header, buffer.Length); } } return(img); }
public override void DrawImage(Image img, double left, double top) { ActualBitmap actualBmp = img as ActualBitmap; if (actualBmp == null) { //test with other bitmap return; } else { DrawBitmap(actualBmp, left, top); } }
public override void DrawImage(Image actualImage, double left, double top, int srcX, int srcY, int srcW, int srcH) { ActualBitmap actualBmp = actualImage as ActualBitmap; if (actualBmp == null) { //test with other bitmap return; } else { DrawBitmap(actualBmp, left, top, srcX, srcY, srcW, srcH); } }
public static AggPainter Create(ActualBitmap bmp, PixelProcessing.PixelBlender32 blender = null) { //helper func AggRenderSurface renderSx = new AggRenderSurface(bmp); if (blender == null) { blender = new PixelProcessing.PixelBlenderBGRA(); } renderSx.PixelBlender = blender; return(new AggPainter(renderSx)); }
public static int[] CopyImgBuffer(ActualBitmap img) { int[] buff2 = new int[img.Width * img.Height]; unsafe { //byte[] pixelBuffer = ActualImage.GetBuffer(img); CpuBlit.Imaging.TempMemPtr pixBuffer = ActualBitmap.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); }
public AggRenderSurface(ActualBitmap destImage) { //create from actual image this.destActualImage = destImage; this.destImageReaderWriter = new MyBitmapBlender(destImage, new PixelBlenderBGRA()); // this.sclineRas = new ScanlineRasterizer(destImage.Width, destImage.Height); this._bmpRasterizer = new DestBitmapRasterizer(); // 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(); }
void DrawBitmap(ActualBitmap actualBmp, double left, double top, int srcX, int srcY, int srcW, int srcH) { //check image caching system if (this._renderQuality == RenderQualtity.Fast) { BitmapBuffer srcBmp = new BitmapBuffer(actualBmp.Width, actualBmp.Height, ActualBitmap.GetBuffer(actualBmp)); try { var src = new BitmapBufferEx.RectD(srcX, srcY, srcW, srcH); var dest = new BitmapBufferEx.RectD(left, top, srcW, srcH); BitmapBuffer bmpBuffer = new BitmapBuffer(actualBmp.Width, actualBmp.Height, ActualBitmap.GetBuffer(actualBmp)); this._bxt.CopyBlit(dest, bmpBuffer, src); } catch (Exception ex) { } return; } //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(actualBmp, left, this.Height - (top + actualBmp.Height), srcX, srcY, srcW, srcH); } else { //left-bottom as original //place left-lower of the img at specific (x,y) this._aggsx.Render(actualBmp, left, top, srcX, srcY, srcW, srcH); } //restore... this.UseSubPixelLcdEffect = useSubPix; _aggsx.UseSubPixelRendering = useSubPix; }
public static int[] CopyImgBuffer(ActualBitmap src, int srcX, int srcY, int srcW, int srcH) { //calculate stride for the width int destStride = ActualBitmap.CalculateStride(srcW, CpuBlit.Imaging.PixelFormat.ARGB32); int newBmpW = destStride / 4; int[] buff2 = new int[newBmpW * srcH]; unsafe { CpuBlit.Imaging.TempMemPtr srcBufferPtr = ActualBitmap.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); NativeMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride); srcIndex += srcStride; destHead2 += destStride; } } srcBufferPtr.Release(); } return(buff2); }
public static void ReplaceBuffer(ActualBitmap img, int[] pixelBuffer) { img.pixelBuffer = pixelBuffer; }
public static int[] GetBuffer(ActualBitmap img) { return(img.pixelBuffer); }
public static CpuBlit.Imaging.TempMemPtr GetBufferPtr(ActualBitmap img) { return(new CpuBlit.Imaging.TempMemPtr(img.pixelBuffer)); }
public override void ReplaceBuffer(int[] newbuffer) { ActualBitmap.ReplaceBuffer(actualImage, newbuffer); }