Пример #1
0
 /// <summary>
 /// Appends a pixel to the file
 /// </summary>
 /// <param name="pixel">Pixel.</param>
 public void AppendRGB(RGB pixel)
 {
     Write (pixel);
     appendIndexHorizontal++;
     if (appendIndexHorizontal > header.ImageWidth) {
         AddPadding();
         appendIndexHorizontal = 0;
     }
 }
Пример #2
0
		public void TakeScreenShot (string directory, string fileName)
		{
				//Console.WriteLine("Create screenshot");
				//Code is taken from the firmware code and simply returns a blank LCD
				int Width = 178;
				int Height = 128;
				BmpImage screenshotImage = new BmpImage (24 * 8, (uint)Height, ColorDepth.TrueColor);
				RGB startColor = new RGB (188, 191, 161);
				RGB endColor = new  RGB (219, 225, 206);
				screenshotImage.Clear ();
				float redActual = (float)endColor.Red;
				float greenActual = (float)endColor.Green;
				float blueActual = (float)endColor.Blue;
				int bytesPrLine = ((Width + 31) / 32) * 4;
				float redGradientStep = (float)(endColor.Red - startColor.Red) / Height; 
				float greenGradientStep = (float)(endColor.Green - startColor.Green) / Height; 
				float blueGradientStep = (float)(endColor.Blue - startColor.Blue) / Height;

				RGB color = new RGB ();
				for (int y = Height - 1; y >= 0; y--) {
					for (int x = 0; x < bytesPrLine * 8; x++) {
						color.Red = (byte)redActual;
						color.Green = (byte)greenActual;
						color.Blue = (byte)blueActual;
						screenshotImage.AppendRGB (color);
					}
					redActual -= redGradientStep;
					greenActual -= greenGradientStep;
					blueActual -= blueGradientStep;
				}
				if (fileName == "") {
					fileName = "ScreenShot" + string.Format ("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now) + ".bmp";
				}
				if (!fileName.ToLower ().EndsWith (".bmp")) 
				{
					fileName = fileName + ".bmp";
				}
				screenshotImage.WriteToFile(System.IO.Path.Combine(directory,fileName));
		}
Пример #3
0
 private void Write(RGB color)
 {
     byte temp;
     switch(header.ColorDepth){
         case ColorDepth.TrueColor:
           Write(color.Blue);
           Write(color.Green);
           Write(color.Red);
           break;
         case ColorDepth.LowColor:
           temp= GetColorIndex(color);
           Write(temp);
           break;
         case ColorDepth.GrayScaleColor:
           temp=color.Red; //red = green = blue
           Write(temp);
           break;
       			}
 }
Пример #4
0
 //This will return the index of the color in the Netscape color cube
 private byte GetColorIndex(RGB color)
 {
     return (byte)((GetCubeIndex(color.Red) * 36) + (GetCubeIndex(color.Green) * 6) + GetCubeIndex(color.Blue));
 }
Пример #5
0
 private RGB[] CreateGrayScalePalette()
 {
     RGB[] palette = new RGB[ColorPaletteSize];
     int index = 0;
     while (index < ColorPaletteSize)
     {
         palette[index] = new RGB();
         palette[index].Red = (byte)index;
         palette[index].Green = (byte)index;
         palette[index].Blue = (byte)index;
         index++;
     }
     return palette;
 }
Пример #6
0
 //For 256 color the Netscape Color Cube is used (http://www.webreference.com/dev/graphics/palette.html)
 private RGB[] CreateColorPalette()
 {
     RGB[] palette = null;
       uint paletteIndex, redIndex, greenIndex, blueIndex;
       RGB temp = new RGB();
       byte[] colorMatrix = new byte[ColorMatrixSize];
       colorMatrix[0] = 0x00;
       colorMatrix[1] = 0x33;
       colorMatrix[2] = 0x66;
       colorMatrix[3] = 0x99;
       colorMatrix[4] = 0xcc;
       colorMatrix[5] = 0xff;
       temp.Red = 0;
       temp.Green = 0;
       temp.Blue = 0;
       palette = new RGB[ColorPaletteSize];
       paletteIndex = 0;
       redIndex = 0;
       while (redIndex < ColorMatrixSize)
       {
     temp.Red = colorMatrix[redIndex];
     greenIndex = 0;
     while (greenIndex < ColorMatrixSize)
     {
       temp.Green = colorMatrix[greenIndex];
       blueIndex = 0;
       while (blueIndex < ColorMatrixSize)
       {
         temp.Blue = colorMatrix[blueIndex];
         palette[paletteIndex] = temp;
         blueIndex++;
         paletteIndex++;
       }
       greenIndex++;
     }
     redIndex++;
       }
       temp.Red = 0xff;
       temp.Green = 0xff;
       temp.Blue = 0xff;
       while (paletteIndex < ColorPaletteSize)
       {
     palette[paletteIndex] = temp;
     paletteIndex++;
       }
       return palette;
 }
Пример #7
0
        public void TakeScreenShot(string directory = "")
        {
            screenshotImage.Clear ();
            float redActual = (float) endColor.Red;
            float greenActual = (float) endColor.Green;
            float blueActual = (float) endColor.Blue;

            RGB color = new RGB ();
            for (int y = Height -1; y >= 0; y--) {
                for (int x = 0; x < bytesPrLine * 8; x++) {
                    if (IsPixelSet (x, y)) {
                        color.Blue = 0x00;
                        color.Green = 0x00;
                        color.Red = 0x00;
                    }
                    else {
                        color.Red = (byte)redActual;
                        color.Green = (byte)greenActual;
                        color.Blue = (byte)blueActual;
                    }
                    screenshotImage.AppendRGB(color);
                }
                redActual -= redGradientStep;
                greenActual-= greenGradientStep;
                blueActual -= blueGradientStep;
            }
            screenshotImage.WriteToFile(System.IO.Path.Combine(directory,"ScreenShot") + string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}",DateTime.Now)+ ".bmp");
        }
Пример #8
0
 //This will return the index of the color in the Netscape color cube
 private byte GetColorIndex(RGB color)
 {
     return((byte)((GetCubeIndex(color.Red) * 36) + (GetCubeIndex(color.Green) * 6) + GetCubeIndex(color.Blue)));
 }