Пример #1
0
 private static void ToYCbCr(IPixelAccessor pixels, int x, int y, Block yBlock, Block cbBlock, Block crBlock)
 {
     int xmax = pixels.Width - 1;
     int ymax = pixels.Height - 1;
     for (int j = 0; j < 8; j++){
         for (int i = 0; i < 8; i++){
             byte[] pixel = pixels[Math.Min(x + i, xmax), Math.Min(y + j, ymax)].ToBytes();
             YCbCr2 color = Color2.FromArgb(pixel[3], pixel[0], pixel[1], pixel[2]);
             int index = 8*j + i;
             yBlock[index] = (int) color.Y;
             cbBlock[index] = (int) color.Cb;
             crBlock[index] = (int) color.Cr;
         }
     }
 }
Пример #2
0
 private void ConvertFromYCbCr(int imageWidth, int imageHeight, ImageBase image)
 {
     int scale = comp[0].h/comp[1].h;
     Color2[] pixels = new Color2[imageWidth*imageHeight];
     Parallel.For(0, imageHeight, Bootstrapper.instance.ParallelOptions, y =>{
         int yo = ycbcrImage.get_row_y_offset(y);
         int co = ycbcrImage.get_row_c_offset(y);
         for (int x = 0; x < imageWidth; x++){
             byte yy = ycbcrImage.pix_y[yo + x];
             byte cb = ycbcrImage.pix_cb[co + (x/scale)];
             byte cr = ycbcrImage.pix_cr[co + (x/scale)];
             int index = y*imageWidth + x;
             Color2 color = new YCbCr2(yy, cb, cr);
             Color2 packed = Color2.FromArgb(color.A, color.R, color.G, color.B);
             pixels[index] = packed;
         }
     });
     image.SetPixels(imageWidth, imageHeight, pixels);
     AssignResolution(image);
 }