Beispiel #1
0
        public static void AddAlpha(Bitmap srcBmp,ImageData alpha)
        {
            if (alpha.Width != srcBmp.Width || alpha.Height != srcBmp.Height)
            {
                return;
            }
            BitmapData srcData = srcBmp.LockBits(new Rectangle(0, 0, srcBmp.Width, srcBmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            unsafe
            {
                byte* src = (byte*)srcData.Scan0;

                int srcOffset = srcData.Stride - srcBmp.Width * 4;
                for (int y = 0; y < srcBmp.Height; ++y)
                {
                    for (int x = 0; x < srcBmp.Width; ++x)
                    {
                        *(src+3) = alpha.Get( x ,y );
                        src += 4;
                    }
                    src += srcOffset;
                }
            }
            srcBmp.UnlockBits(srcData);
        }
Beispiel #2
0
        public unsafe ImageData Clone()
        {
            ImageData clone = new ImageData(Width,Height);
            memcpy((byte*)clone.Buf, (byte*)Buf, m_width * m_height);

            return clone;
        }