protected void DisplayJPG() { var jpgData = LoadResource("meadow.jpg"); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); int x = 0; int y = 0; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; graphics.DrawPixel(x + 55, y + 40, Color.FromRgb(r, g, b)); x++; if (x % decoder.Width == 0) { y++; x = 0; } } display.Show(); }
void DisplayJPG(int weatherCode, int xOffset, int yOffset) { var jpgData = LoadResource(weatherCode); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); int x = 0; int y = 0; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; graphics.DrawPixel(x + xOffset, y + yOffset, Color.FromRgb(r, g, b)); x++; if (x % decoder.Width == 0) { y++; x = 0; } } }
void DisplayJPG(int x, int y) { var jpgData = LoadResource("meadow.jpg"); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); int imageX = 0; int imageY = 0; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; graphics.DrawPixel(imageX + x, imageY + y, Color.FromRgb(r, g, b)); imageX++; if (imageX % decoder.Width == 0) { imageY++; imageX = 0; } } display.Show(); }
void UpdateImage(int index, int xOffSet, int yOffSet) { var jpgData = LoadResource($"level_{index}.jpg"); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); int x = 0; int y = 0; byte r, g, b; graphics.DrawRectangle(0, 0, 240, 208, Color.White, true); for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; graphics.DrawPixel(x + xOffSet, y + yOffSet, Color.FromRgb(r, g, b)); x++; if (x % decoder.Width == 0) { y++; x = 0; } } graphics.Show(); }
void DisplayJPG() { var jpgData = LoadResource(images[selectedIndex]); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); int x = 0; int y = 0; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; graphics.DrawPixel(x, y, Color.FromRgb(r, g, b)); x++; if (x % decoder.Width == 0) { y++; x = 0; } } graphics.Show(); }
void JpegTest() { Console.WriteLine("Jpeg Test"); var jpgData = LoadResource("meadow.jpg"); Console.WriteLine($"Loaded {jpgData.Length} bytes, decoding jpeg ..."); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); Console.WriteLine($"Jpeg decoded is {jpg.Length} bytes"); Console.WriteLine($"Width {decoder.Width}"); Console.WriteLine($"Height {decoder.Height}"); graphics.Clear(); graphics.DrawRectangle(0, 0, 240, 320, Color.White, true); int x = 0; int y = (320 - decoder.Height) / 2; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; display.DrawPixel(x, y, r, g, b); x++; if (x % decoder.Width == 0) { y++; x = 0; } } Console.WriteLine("Jpeg show"); display.Show(); }
void ShowJpeg() { var jpgData = this.LoadResource(images[this.selectedIndex]); var decoder = new JpegDecoder(); var jpg = decoder.DecodeJpeg(jpgData); Console.WriteLine($"Jpeg decoded is {jpg.Length} bytes"); Console.WriteLine($"Width {decoder.Width}"); Console.WriteLine($"Height {decoder.Height}"); this.graphics.Clear(); this.display.Show(); int x = 0; int y = 0; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; graphics.DrawPixel(x, y, Color.FromRgb(r, g, b)); x++; if (x % decoder.Width == 0) { y++; x = 0; } } this.display.Show(); }
void CameraTest() { Console.WriteLine("Set image size"); camera.SetImageSize(Vc0706.ImageSize._320x240); Console.WriteLine($"Image size is {camera.GetImageSize()}"); Console.WriteLine("Set TV off"); camera.TvOff(); Thread.Sleep(2000); Console.WriteLine("Set TV on"); camera.TvOn(); Thread.Sleep(2000); Console.WriteLine(camera.GetVersion()); Thread.Sleep(2000); camera.SetOnScreenDisplay(10, 10, "Hi"); Thread.Sleep(2000); Console.WriteLine("Take picture"); camera.TakePicture(); uint frameLen = camera.GetFrameLength(); Console.WriteLine($"Frame length: {frameLen}"); byte bytesToRead; byte[] jpg; var decoder = new JpegDecoder(); using (var stream = new MemoryStream()) { Console.WriteLine($"Decode jpeg - this operation may take serveral seconds"); while (frameLen > 0) { bytesToRead = (byte)Math.Min(32, frameLen); var buffer = camera.ReadPicture(bytesToRead); stream.Write(buffer, 0, bytesToRead); frameLen -= bytesToRead; } jpg = decoder.DecodeJpeg(stream.ToArray()); } Console.WriteLine($"Jpeg data length: {jpg.Length}"); Console.WriteLine($"Jpeg decoded is {decoder.ImageSize} bytes"); Console.WriteLine($"Width {decoder.Width}"); Console.WriteLine($"Height {decoder.Height}"); Console.WriteLine($"IsColor {decoder.IsColor}"); graphics.Clear(); graphics.DrawRectangle(0, 0, 240, 320, Color.White, true); int x = 0; int y = 0; //int y = (320 - image.Height) / 2; byte r, g, b; for (int i = 0; i < jpg.Length; i += 3) { r = jpg[i]; g = jpg[i + 1]; b = jpg[i + 2]; display.DrawPixel(y, x, r, g, b); x++; if (x % decoder.Width == 0) { y++; x = 0; } } Console.WriteLine("Jpeg show"); camera.TvOn(); display.Show(); }