QuickFont.JBitmap.BlitMax C# (CSharp) 메소드

BlitMax() 공개 메소드

public BlitMax ( JBitmap target, int px, int py, float strength ) : void
target JBitmap
px int
py int
strength float
리턴 void
        public void BlitMax(JBitmap target, int px, int py, float strength)
        {

            //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);
                    int max;

                    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++)
                        {
                            max = Math.Max((int)*(targetOffset), (int) (*(sourceOffset) * strength));

                            if (*(sourceOffset) * strength > *(targetOffset))
                            {
                                max = (int) (*(sourceOffset) * strength );

                                if (max > 255)
                                {
                                    *(targetOffset) = 255;
                                }
                                else
                                {
                                    *(targetOffset) = (byte)max;
                                }
                            }




                        }

                    }
                }


            }



        }