Пример #1
0
        private PictureRow BuildRow()
        {
            PictureRow _newPictureRow = new PictureRow(_picture.ResolutionX, OutputColorFormat);

            //Read one Line from stream
            for (int i = 0; i < _picture.ResolutionX; i++)
            {
                //At this Point we need to different between the Colorformats
                switch (OutputColorFormat)
                {
                case EnumColorFormat.YUV:     //TODO: Complete yuv build (for the moment just luminance is written)
                    var pixelByte = new byte[2];
                    pixelByte[0] = _receivedData.Dequeue();
                    pixelByte[1] = _receivedData.Dequeue();
                    var pixelForYuv = Color.FromArgb((int)pixelByte[0], (int)pixelByte[0], (int)pixelByte[0]);     //Add in each Colorchannel the same Y Value to get a grey Color
                    _newPictureRow.AddPixel(pixelForYuv);

                    break;

                case EnumColorFormat.BayerRaw:
                    break;

                case EnumColorFormat.ProcessedBayerRaw:
                    var pixelBytes = new byte[3];
                    pixelBytes[0] = _receivedData.Dequeue();
                    pixelBytes[1] = _receivedData.Dequeue();
                    pixelBytes[2] = _receivedData.Dequeue();
                    //TODO: make a differntiation between the different color formats of the image and check if Color Format is known otherwise throw exception
                    var pixel = Color.FromArgb((int)pixelBytes[0], (int)pixelBytes[1], (int)pixelBytes[2]);
                    _newPictureRow.AddPixel(pixel);
                    break;

                case EnumColorFormat.RGB444:       //RGB444:8G8R 8G8B
                                                   //TODO: include colorformat: RGB444 4:2:2
                    break;

                case EnumColorFormat.RGB565:
                    var pixelBytesRGB565 = new byte[2];
                    pixelBytesRGB565[0] = _receivedData.Dequeue();
                    pixelBytesRGB565[1] = _receivedData.Dequeue();
                    var _newColorRGB565 = new ColorFormat();
                    _newColorRGB565.ColorRgb565Value = pixelBytesRGB565;
                    _newPictureRow.AddPixel(_newColorRGB565.ColorRgb888);
                    break;

                case EnumColorFormat.RGB555:
                    //TODO: Add ColorFormat (COM15)
                    break;

                case EnumColorFormat.NotSelected:
                    break;
                }
            }

            return(_newPictureRow);
        }
Пример #2
0
 /// <summary>
 /// This is the prefered function to add a complete row to an image.
 /// </summary>
 /// <param name="pictureRow"></param>
 /// an object that includes all information of one pixelrow
 /// <param name="row"></param>
 /// certain row number which should be added
 /// <returns></returns>
 /// 0: everything worked out proper
 /// -1: xResolution of image and of the Pixelrow do not match
 /// -2: the row number do not fit to the image
 public int AddLineToImage(PictureRow pictureRow, int row)
 {
     //if xResolution of PixelRow do not fit to xResolution of the Image return an error
     if (pictureRow.xRes != ResolutionX)
     {
         return(-1);
     }
     if (row >= ResolutionY)
     {
         return(-2);
     }
     //write all Pixels into the Line.
     for (int i = 0; i < ResolutionX; i++)
     {
         Image.SetPixel(i, row, pictureRow.pixelRowList[i].ColorRgb888);
     }
     return(0);
 }
Пример #3
0
 /// <summary>
 /// This is the prefered function to add a complete row to an image. The rowCounter isincreases automaticly after adding a row
 /// </summary>
 /// <param name="pictureRow"></param>
 /// an object that includes all information of one pixelrow
 /// <returns></returns>
 /// 0: everything worked out proper
 /// -1: xResolution of image and of the Pixelrow do not match
 /// -2: to many Lines would be added to the image
 public int AddLineToImage(PictureRow pictureRow)
 {
     //if xResolution of PixelRow do not fit to xResolution of the Image return an error
     if (pictureRow.xRes != ResolutionX)
     {
         return(-1);
     }
     //check if not to many Lines will be added to the image
     if (_rowCounter >= ResolutionY)
     {
         return(-2);
     }
     //write all Pixels into the Line.
     for (int i = 0; i < ResolutionX; i++)
     {
         Image.SetPixel(i, _rowCounter, pictureRow.pixelRowList[i].ColorRgb888);
     }
     _rowCounter++;
     return(0);
 }