예제 #1
0
 private void Rotate90_Click(object sender, EventArgs e)
 {
     pictureBox1.Image = ImageManipulation.RotateImage(pictureBox1.Image, ImageManipulation.RotateMode.Ninetee);
 }
예제 #2
0
 private void Rotate180_Click(object sender, EventArgs e)
 {
     pictureBox1.Image = ImageManipulation.RotateImage(pictureBox1.Image,
         ImageManipulation.RotateMode.OneHundretEighty);
 }
예제 #3
0
 private void Rotate270_Click(object sender, EventArgs e)
 {
     pictureBox1.Image = ImageManipulation.RotateImage(pictureBox1.Image,
         ImageManipulation.RotateMode.TwoHundredSeventy);
 }
예제 #4
0
파일: EPD.cs 프로젝트: Spatacoli/net-reader
        public byte[] getBuffer(Bitmap image)
        {
            byte[] buf      = new byte[EPD_WIDTH * EPD_HEIGHT / 2];
            int    imwidth  = image.Width;
            int    imheight = image.Height;

            _log.LogDebug($"imwidth = {imwidth} imheight = {imheight}");
            if (imheight == EPD_WIDTH && imwidth == EPD_HEIGHT)
            {
                _log.LogDebug("Need to rotate image");
                image    = ImageManipulation.RotateImage(image);
                imwidth  = image.Width;
                imheight = image.Height;
            }

            if (imwidth == EPD_WIDTH && imheight == EPD_HEIGHT)
            {
                _log.LogDebug("Width and Height match!");
                for (int y = 0; y < imheight; y++)
                {
                    for (int x = 0; x < imwidth; x++)
                    {
                        int   add        = (int)((x + y * EPD_WIDTH) / 2);
                        int   color      = 0;
                        Color pixelColor = image.GetPixel(x, y);
                        if (pixelColor == Color.FromArgb(0x00, 0x00, 0x00))
                        {
                            color = 0x00;
                        }
                        else if (pixelColor == Color.FromArgb(0xFF, 0xFF, 0xFF))
                        {
                            color = 0x01;
                        }
                        else if (pixelColor == Color.FromArgb(0x00, 0xFF, 0x00))
                        {
                            color = 0x02;
                        }
                        else if (pixelColor == Color.FromArgb(0x00, 0x00, 0xFF))
                        {
                            color = 0x03;
                        }
                        else if (pixelColor == Color.FromArgb(0xFF, 0x00, 0x00))
                        {
                            color = 0x04;
                        }
                        else if (pixelColor == Color.FromArgb(0xFF, 0xFF, 0x00))
                        {
                            color = 0x05;
                        }
                        else if (pixelColor == Color.FromArgb(0xFF, 0x80, 0x00))
                        {
                            color = 0x06;
                        }
                        else
                        {
                            color = 0x07;
                        }
                        int data_t = buf[add] & (~(0xF0 >> ((x % 2) * 4)));
                        buf[add] = Convert.ToByte(data_t | ((color << 4) >> ((x % 2) * 4)));
                    }
                }
            }
            else
            {
                _log.LogDebug($"Image size is wrong. Must be {EPD_WIDTH}x{EPD_HEIGHT} but instead is {imwidth}x{imheight}");
            }
            return(buf);
        }