QuickFont.JBitmap.BlitOLD C# (CSharp) Method

BlitOLD() public method

Blits this bitmap onto the target - clips regions that are out of bounds. Only supported for 8bbp
public BlitOLD ( JBitmap target, int px, int py ) : void
target JBitmap
px int
py int
return void
        public void BlitOLD(JBitmap target, int px, int py){

            //currently only supported for 8 bpp source / target
            if (bitmapData.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed &&
                target.bitmapData.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
            {


                    int targetStartX, targetEndX;
                    int targetStartY, targetEndY;
                    int copyW, copyH;

                    targetStartX = Math.Max(px,0);
                    targetEndX = Math.Min(px + bitmapData.Width, target.bitmapData.Width);
                    
                    targetStartY = Math.Max(py,0);
                    targetEndY = Math.Min(py + bitmapData.Height, target.bitmapData.Height);

                    copyW = targetEndX - targetStartX;
                    copyH = targetEndY - targetStartY;

                    if(copyW < 0 ){
                        return;
                    }

                    if(copyH < 0){
                        return;
                    }

                    int sourceStartX = targetStartX - px;
                    int sourceStartY = targetStartY - py;


                unsafe
                {
                    byte* sourcePtr = (byte*)(bitmapData.Scan0);
                    byte* targetPtr = (byte*)(target.bitmapData.Scan0);


                    byte* targetY = targetPtr + targetStartY * target.bitmapData.Stride;
                    byte* sourceY = sourcePtr + sourceStartY * bitmapData.Stride;
                    for (int y = 0; y < copyH; y++, targetY += target.bitmapData.Stride, sourceY += bitmapData.Stride)
                    {

                        byte* targetOffset = targetY + targetStartX;
                        byte* sourceOffset = sourceY + sourceStartX;
                        for (int x = 0; x < copyW; x++, targetOffset++, sourceOffset++)
                        {
                            *(targetOffset) = *(sourceOffset);

                        }
                        
                    }
                }


            }



        }