Example #1
0
        public bool CopyImg(Int32 offX, Int32 offY, DevImage image)
        {
            //*
            if(image == null) return false;
            if((image.Width  > m_width - offX) && (image.Height > m_height - offY)) return false;

            LockBitmap();
            image.LockBitmap();

            byte[] val = new byte[4];

            for (int i = 0; i < image.Height; i++)
            {
                for (int j = 0; j < image.m_width; j++)
                {
                    val[0] = image.GetPixel(j, i).A;
                    val[1] = image.GetPixel(j, i).R;
                    val[2] = image.GetPixel(j, i).G;
                    val[3] = image.GetPixel(j, i).B;
                    SetPixel(offX + j, offY + i, val);
                }
            }

            image.UnlockBitmap();
            UnlockBitmap();
            return true;
            /**/

            //Bitmap bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb);
            //Graphics g = Graphics.FromImage(bmp);

            //g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height,
            //                    GraphicsUnit.Pixel);
            //g.Dispose();
            //return true;
        }
Example #2
0
 public static Bitmap GetNoAlphaBitmap(DevImage img)
 {
     Bitmap bmp = img.BmpImage;
     for (int column = 0; column < img.Width; column++)
     {
         for (int row = 0; row < img.Height; row++)
         {
             Color color = Color.FromArgb(img.GetPixel(column, row).R, img.GetPixel(column, row).G, img.GetPixel(column, row).B);
             bmp.SetPixel(column, row, color);
         }
     }
     return bmp;
 }
Example #3
0
        public static Bitmap SplitImage(DevImage image, Rectangle rect)
        {
            Bitmap destBmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);

            image.LockBitmap();
            BitmapData destData = destBmp.LockBits(new Rectangle(0, 0, destBmp.Width, destBmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            byte* pDest = (byte*)destData.Scan0;
            int offset = destData.Stride - destBmp.Width * 4;
            for (int y = 0; y < destBmp.Height; ++y)
            {
                for (int x = 0; x < destBmp.Width; ++x)
                {
                    Color color = image.GetPixel(x + rect.Left, y + rect.Top);
                    *(pDest++) = color.R;
                    *(pDest++) = color.G;
                    *(pDest++) = color.B;
                    *(pDest++) = color.A;
                }
                pDest += offset;
            }

            image.UnlockBitmap();
            destBmp.UnlockBits(destData);
            return destBmp;
        }