//public CompressionHandler(Color[,] inputArray2D, int pixelMaxX, int pixelMaxY) //{ // this.inputArray2D = inputArray2D; // this.pixelMaxX = pixelMaxX; // this.pixelMaxY = pixelMaxY; //} // Only if no values are given, default values are set to 0 public CompressionHandler(Color3[,] inputArray2D, int pixelMaxX, int pixelMaxY, byte aPattern = 0, byte bPattern = 0, byte cPattern = 0, byte colorPattern = 0) { this.inputArray2D = inputArray2D; this.pixelMaxX = pixelMaxX; this.pixelMaxY = pixelMaxY; this.aPattern= aPattern; this.bPattern = bPattern; this.cPattern = cPattern; this.ColorPattern = colorPattern; outputArray2D = new Color[inputArray2D.GetLength(0), inputArray2D.GetLength(1)]; }
//Bitmap test public void TestChannelResolutionReduction(string inputFile, string outputFile) { // load Bitmap .png Bitmap bitmap = new Bitmap(inputFile); Color[,] picture = new Color[bitmap.Height, bitmap.Width]; for (int x = 0; x < bitmap.Width; x++) { for (int y = 0; y < bitmap.Height; y++) { var bitmapPixel = bitmap.GetPixel(x, y); // sets RGB for each pixel Color3 newPixel = new Color3 { a = bitmapPixel.R, b = bitmapPixel.G, c = bitmapPixel.B }; picture[y, x] = newPixel; } } // CompressionHandler compressionHandler = new CompressionHandler(picture, bitmap.Width, bitmap.Height); // // compressionhandler dont neednead parameter yet // Color[,] result = compressionHandler.LocalAveraging444To422(0xDEAD); // Bitmap resultImage = new Bitmap(bitmap.Width, bitmap.Height); // for (int y = 0; y < bitmap.Height; y++) // { // for (int x = 0; x < bitmap.Width; x++) // { // // draws image // System.Drawing.Color color = System.Drawing.Color.FromArgb(result[y, x].a, result[y, x].b, result[y, x].c); // resultImage.SetPixel(x, y, color); // } // } // resultImage.Save(outputFile); }
/// <summary> /// fixed sampling scheme 4:2:0, colorPattern not considered /// </summary> /// <param name="inputCompression"></param> /// <returns></returns> public Color[,] LocalAveraging(int inputCompression) { Color[,] outputArray2D; outputArray2D = new Color[pixelMaxY, pixelMaxX]; //Konstrukt befüllt die Ausgabe mit Color1 Werten (Y-Farbe) for (int y = 0; y < pixelMaxY; y++) { for (int x = 0; x < pixelMaxX; x++) { outputArray2D[y, x] = inputArray2D[y, x].ConvertToColor1(); } } //Alle Werte auf der x-Achse werden abhängig der Kompression in den ersten Pixel des Intervalls gespeichert Color3[,] tempArray; tempArray = new Color3[pixelMaxX, pixelMaxY]; for(int y = 0; y< pixelMaxY; y++) { for(int x = 0; x<pixelMaxX; x = x+inputCompression) { int count = 0;//Schrittzähler um bei ungerader Auflösung korrekte Mittelung zu erhalten for (int z = x; z<x+inputCompression; z++) { if (z > pixelMaxX) break; else { tempArray[y, x].Color3AdditionB(inputArray2D[y, z]); //outputArray2D[y, x].b += inputArray2D[y, z].b; tempArray[y, x].Color3AdditionC(inputArray2D[y, z]); // outputArray2D[y, x].c += inputArray2D[y, z].c; } count++; } tempArray[y, x].Color3DivisionB(count); tempArray[y, x].Color3DivisionC(count); //outputArray2D[y, x].c = (byte) (outputArray2D[y, x].c / count); } } //Alle Werte in y-Richtung, abhänig der Kompression werden in den ersten Pixel gespeichert for (int y = 0; y<pixelMaxY; y= y+ inputCompression) { for(int x = 0; x<pixelMaxX; x = x+inputCompression) { int count = 0; for(int z = y+1; z< y+inputCompression; z++) { if (z > pixelMaxY) break; else { tempArray[y, x].Color3AdditionB(tempArray[z, x]); tempArray[y, x].Color3AdditionC(tempArray[z, x]); //outputArray2D[y, x].b += outputArray2D[z, x].b; //outputArray2D[y, x].c += outputArray2D[z, x].c; } count++; } //outputArray2D[y, x].b = (byte) (outputArray2D[y, x].b / count); //outputArray2D[y, x].c = (byte) (outputArray2D[y, x].c / count); tempArray[y, x].Color3DivisionB(count); tempArray[y, x].Color3DivisionC(count); tempArray[y, x].a = inputArray2D[y, x].a; outputArray2D[y, x] = tempArray[y, x]; } } return outputArray2D; //alle 1Vector Koordinaten //for (int y = 0; y < pixelMaxY;y= y+inputCompression) //{ // for (int x = 0; x < pixelMaxX; x=x + inputCompression) // { // outputArray2D[y, x].b = inputArray2D[y, x].b; // outputArray2D[y, x].c = inputArray2D[y, x].c; // } // } //return outputArray2D; }
public bool testZickZackbyte() { byte[,] test = new byte[4, 6] { { 1, 2, 6, 7, 14, 15 }, { 3, 5, 8, 13, 16, 21 }, { 4, 9, 12, 17, 20, 22 }, { 10, 11, 18, 19, 23, 24 } }; byte[,] test2 = new byte[4, 7] { { 1, 2, 6, 7, 14, 15, 22 }, { 3, 5, 8, 13, 16, 21, 23 }, { 4, 9, 12, 17, 20, 24, 27 }, { 10, 11, 18, 19, 25, 26, 28 } }; byte[,] test3 = new byte[5, 7] { { 1, 2, 6, 7, 15, 16, 25 }, { 3, 5, 8, 14, 17, 24, 26 }, { 4, 9, 13, 18, 23, 27, 32 }, { 10, 12, 19, 22, 28, 31, 33 }, { 11, 20, 21, 29, 30, 34, 35 } }; byte[,] test4 = new byte[5, 6] { { 1, 2, 6, 7, 15, 16 }, { 3, 5, 8, 14, 17, 24 }, { 4, 9, 13, 18, 23, 25 }, { 10, 12, 19, 22, 26, 29 }, { 11, 20, 21, 27, 28, 30 } }; byte[,] test5 = new byte[6, 4] { { 1, 2, 6, 7 }, { 3, 5, 8, 14 }, { 4, 9, 13, 15 }, { 10, 12, 16, 21 }, { 11, 17, 20, 22 }, { 18, 19, 23, 24 } }; byte[,] test6 = new byte[7, 6] { { 1, 2, 6, 7, 15, 16 }, { 3, 5, 8, 14, 17, 27 }, { 4, 9, 13, 18, 26, 28 }, { 10, 12, 19, 25, 29, 36 }, { 11, 20, 24, 30, 35, 37 }, { 21, 23, 31, 34, 38, 41 }, { 22, 32, 33, 39, 40, 42 } }; byte[,] test7 = new byte[7, 5] { { 1, 2, 6, 7, 15 }, { 3, 5, 8, 14, 16 }, { 4, 9, 13, 17, 25 }, { 10, 12, 18, 24, 26 }, { 11, 19, 23, 27, 32 }, { 20, 22, 28, 31, 33 }, { 21, 29, 30, 34, 35 } }; byte[,] test8 = new byte[6, 5] { { 1, 2, 6, 7, 15 }, { 3, 5, 8, 14, 16 }, { 4, 9, 13, 17, 24 }, { 10, 12, 18, 23, 25 }, { 11, 19, 22, 26, 29 }, { 20, 21, 27, 28, 30 } }; byte[] restest = new byte[24]; byte[] restest2 = new byte[28]; byte[] restest3 = new byte[35]; byte[] restest4 = new byte[30]; for (byte i = 0; i < 24; i++) { restest[i] = (byte)(i + 1); } for (byte i = 0; i < 28; i++) { restest2[i] = (byte)(i + 1); } for (byte i = 0; i < 35; i++) { restest3[i] = (byte)(i + 1); } for (byte i = 0; i < 30; i++) { restest4[i] = (byte)(i + 1); } var result1 = false; var res = testmath.ZickZackScanByte(test); var res2 = testmath.ZickZackScanByte(test2); var res3 = testmath.ZickZackScanByte(test3); var res4 = testmath.ZickZackScanByte(test4); if (res.SequenceEqual(restest) && res2.SequenceEqual(restest2) && res3.SequenceEqual(restest3) && res4.SequenceEqual(restest4)) { result1 = true; } byte[] restest5 = new byte[24]; byte[] restest6 = new byte[42]; byte[] restest7 = new byte[35]; byte[] restest8 = new byte[30]; for (byte i = 0; i < 24; i++) { restest5[i] = (byte)(i + 1); } for (byte i = 0; i < 42; i++) { restest6[i] = (byte)(i + 1); } for (byte i = 0; i < 35; i++) { restest7[i] = (byte)(i + 1); } for (byte i = 0; i < 30; i++) { restest8[i] = (byte)(i + 1); } var result2 = false; //passt var res5 = testmath.ZickZackScanByte(test5); var res6 = testmath.ZickZackScanByte(test6); var res7 = testmath.ZickZackScanByte(test7); var res8 = testmath.ZickZackScanByte(test8); if (res5.SequenceEqual(restest5) && res6.SequenceEqual(restest6) && res7.SequenceEqual(restest7) && res8.SequenceEqual(restest8)) { result2 = true; } if (result1 && result2) { return(true); } return(false); //Color example Color[] Colortest = new Color[10]; Color3 col3 = new Color3(); Color1 col1 = new Color1(); Colortest[1] = col3; Colortest[2] = col1; }
/// <summary> /// fixed sampling scheme 4:2:0, colorPattern not considered /// </summary> /// <param name="inputCompression"></param> /// <returns></returns> public Color[,] LocalAveraging(int inputCompression) { Color[,] outputArray2D; outputArray2D = new Color[pixelMaxY, pixelMaxX]; //Konstrukt befüllt die Ausgabe mit Color1 Werten (Y-Farbe) for (int y = 0; y < pixelMaxY; y++) { for (int x = 0; x < pixelMaxX; x++) { outputArray2D[y, x] = inputArray2D[y, x].ConvertToColor1(); } } //Alle Werte auf der x-Achse werden abhängig der Kompression in den ersten Pixel des Intervalls gespeichert Color3[,] tempArray; tempArray = new Color3[pixelMaxX, pixelMaxY]; for (int y = 0; y < pixelMaxY; y++) { for (int x = 0; x < pixelMaxX; x = x + inputCompression) { int count = 0;//Schrittzähler um bei ungerader Auflösung korrekte Mittelung zu erhalten for (int z = x; z < x + inputCompression; z++) { if (z > pixelMaxX) { break; } else { tempArray[y, x].Color3AdditionB(inputArray2D[y, z]); //outputArray2D[y, x].b += inputArray2D[y, z].b; tempArray[y, x].Color3AdditionC(inputArray2D[y, z]); // outputArray2D[y, x].c += inputArray2D[y, z].c; } count++; } tempArray[y, x].Color3DivisionB(count); tempArray[y, x].Color3DivisionC(count); //outputArray2D[y, x].c = (byte) (outputArray2D[y, x].c / count); } } //Alle Werte in y-Richtung, abhänig der Kompression werden in den ersten Pixel gespeichert for (int y = 0; y < pixelMaxY; y = y + inputCompression) { for (int x = 0; x < pixelMaxX; x = x + inputCompression) { int count = 0; for (int z = y + 1; z < y + inputCompression; z++) { if (z > pixelMaxY) { break; } else { tempArray[y, x].Color3AdditionB(tempArray[z, x]); tempArray[y, x].Color3AdditionC(tempArray[z, x]); //outputArray2D[y, x].b += outputArray2D[z, x].b; //outputArray2D[y, x].c += outputArray2D[z, x].c; } count++; } //outputArray2D[y, x].b = (byte) (outputArray2D[y, x].b / count); //outputArray2D[y, x].c = (byte) (outputArray2D[y, x].c / count); tempArray[y, x].Color3DivisionB(count); tempArray[y, x].Color3DivisionC(count); tempArray[y, x].a = inputArray2D[y, x].a; outputArray2D[y, x] = tempArray[y, x]; } } return(outputArray2D); //alle 1Vector Koordinaten //for (int y = 0; y < pixelMaxY;y= y+inputCompression) //{ // for (int x = 0; x < pixelMaxX; x=x + inputCompression) // { // outputArray2D[y, x].b = inputArray2D[y, x].b; // outputArray2D[y, x].c = inputArray2D[y, x].c; // } // } //return outputArray2D; }
public void PPMtoJpg(string imageSrc, string imagedest) { Bitstream bs = new Bitstream(); PlainFormatReader pfr = new PlainFormatReader(imageSrc); Mathloc ml = new Mathloc(); Picture pic = pfr.ReadPicture(); int height = pic.Head.pixelMaxY; int width = pic.Head.pixelMaxX; Color3[,] col3 = new Color3[height, width]; byte[] colors = new byte[3]; //convert RGB to YUV for each pixel for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { col3[y, x] = pic.Data.PictureYX[y, x]; colors[0] = col3[y, x].a; // R colors[1] = col3[y, x].b; // G colors[2] = col3[y, x].c; // B colors = ml.RGBToYUV(colors); col3[y, x].a = colors[0]; // Y col3[y, x].b = colors[1]; // U col3[y, x].c = colors[2]; // V } } //convert float array to byte array float[,] yArray = new float[width, height]; // width and height vertauscht float[,] uArray = new float[width, height]; float[,] vArray = new float[width, height]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { yArray[i, j] = (float)col3[j, i].a; uArray[i, j] = (float)col3[j, i].b; vArray[i, j] = (float)col3[j, i].c; } } byte[,] yArrayEnde = new byte[width, height]; byte[,] uArrayEnde = new byte[width, height]; byte[,] vArrayEnde = new byte[width, height]; //get float [number of 8x8][8x8] var yarry = aufteilen(yArray); var uarry = aufteilen(uArray); var varry = aufteilen(vArray); //geht beim 40x40 bild 25 for (int y = 0; y < height / 8; y++) { for (int x = 0; x < width / 8; x++) { //DCTDirect for (int i = 0; i < ((height * width) / 64); i++) { yArray = DCT.DCTdirect(yarry[i]); uArray = DCT.DCTdirect(uarry[i]); vArray = DCT.DCTdirect(varry[i]); } //convert float array to byte array byte[,] yArrayB = new byte[width, height]; byte[,] uArrayB = new byte[width, height]; byte[,] vArrayB = new byte[width, height]; for (int i = 0; i < width / 8; i++) { for (int j = 0; j < height / 8; j++) { yArrayB[i, j] = (byte)yArray[i, j]; uArrayB[i, j] = (byte)uArray[i, j]; vArrayB[i, j] = (byte)vArray[i, j]; } } for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { yArrayEnde[i * x, j *y] = yArrayB[i, j]; uArrayEnde[i * x, j *y] = uArrayB[i, j]; vArrayEnde[i * x, j *y] = vArrayB[i, j]; } } byte[] yArrayB2 = new byte[64]; byte[] uArrayB2 = new byte[64]; byte[] vArrayB2 = new byte[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { yArrayB2[ZigZagTable2[i * j]] = yArrayB[i, j]; uArrayB2[ZigZagTable2[i * j]] = uArrayB[i, j]; vArrayB2[ZigZagTable2[i * j]] = vArrayB[i, j]; } } // Create Huffmantables //yArrayEnde = HuffmanCalc(YDCNodes, YDCValues, yArrayB2); //yArrayEnde = HuffmanCalc(YDCNodes, YACValues, yArrayB2); //uArrayEnde = HuffmanCalc(CbDCNodes, CbDCValues, uArrayB2); //uArrayEnde = HuffmanCalc(CbACNodes, CbACValues, uArrayB2); //vArrayEnde = HuffmanCalc(CbDCNodes, CbDCValues, vArrayB2); //vArrayEnde = HuffmanCalc(CbACNodes, CbACValues, vArrayB2); } } //create JPG head PictureHead.CreateJPGHead(bs, (ushort)height, (ushort)width); //TODO: DCT for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { bs.AddByte((byte)yArrayEnde[x, y]); bs.AddByte((byte)uArrayEnde[x, y]); bs.AddByte((byte)vArrayEnde[x, y]); } } bs.AddShort(0xffd9); //End of Picture Marker bs.WriteToFile(imagedest); }
public bool testZickZackbyte() { byte[,] test = new byte[4, 6] {{1, 2, 6, 7, 14, 15}, {3, 5, 8, 13, 16, 21}, {4, 9, 12, 17, 20, 22}, {10, 11, 18, 19, 23, 24}}; byte[,] test2 = new byte[4, 7] { {1, 2, 6, 7, 14, 15, 22}, {3, 5, 8, 13, 16, 21, 23}, {4, 9, 12, 17, 20, 24, 27}, {10, 11, 18, 19, 25, 26, 28} }; byte[,] test3 = new byte[5, 7] { {1, 2, 6, 7, 15, 16, 25}, {3, 5, 8, 14, 17, 24, 26}, {4, 9, 13, 18, 23, 27, 32}, {10, 12, 19, 22, 28, 31, 33}, {11, 20, 21, 29, 30, 34, 35} }; byte[,] test4 = new byte[5, 6] { {1, 2, 6, 7, 15, 16}, {3, 5, 8, 14, 17, 24}, {4, 9, 13, 18, 23, 25}, {10, 12, 19, 22, 26, 29}, {11, 20, 21, 27, 28, 30} }; byte[,] test5 = new byte[6, 4] {{1, 2, 6, 7}, {3, 5, 8, 14}, {4, 9, 13, 15}, {10, 12, 16, 21}, {11, 17, 20, 22}, {18, 19, 23, 24}}; byte[,] test6 = new byte[7, 6] { {1, 2, 6, 7, 15, 16}, {3, 5, 8, 14, 17, 27}, {4, 9, 13, 18, 26, 28}, {10, 12, 19, 25, 29, 36}, {11, 20, 24, 30, 35, 37}, {21, 23, 31, 34, 38, 41}, {22, 32, 33, 39, 40, 42} }; byte[,] test7 = new byte[7, 5] { {1, 2, 6, 7, 15}, {3, 5, 8, 14, 16}, {4, 9, 13, 17, 25}, {10, 12, 18, 24, 26}, {11, 19, 23, 27, 32}, {20, 22, 28, 31, 33}, {21, 29, 30, 34, 35} }; byte[,] test8 = new byte[6, 5] { {1, 2, 6, 7, 15}, {3, 5, 8, 14, 16}, {4, 9, 13, 17, 24}, {10, 12, 18, 23, 25}, {11, 19, 22, 26, 29}, {20, 21, 27, 28, 30} }; byte[] restest = new byte[24]; byte[] restest2 = new byte[28]; byte[] restest3 = new byte[35]; byte[] restest4 = new byte[30]; for (byte i = 0; i < 24; i++) { restest[i] = (byte) (i + 1); } for (byte i = 0; i < 28; i++) { restest2[i] = (byte) (i + 1); } for (byte i = 0; i < 35; i++) { restest3[i] = (byte) (i + 1); } for (byte i = 0; i < 30; i++) { restest4[i] = (byte) (i + 1); } var result1 = false; var res = testmath.ZickZackScanByte(test); var res2 = testmath.ZickZackScanByte(test2); var res3 = testmath.ZickZackScanByte(test3); var res4 = testmath.ZickZackScanByte(test4); if (res.SequenceEqual(restest) && res2.SequenceEqual(restest2) && res3.SequenceEqual(restest3) && res4.SequenceEqual(restest4)) { result1 = true; } byte[] restest5 = new byte[24]; byte[] restest6 = new byte[42]; byte[] restest7 = new byte[35]; byte[] restest8 = new byte[30]; for (byte i = 0; i < 24; i++) { restest5[i] = (byte) (i + 1); } for (byte i = 0; i < 42; i++) { restest6[i] = (byte) (i + 1); } for (byte i = 0; i < 35; i++) { restest7[i] = (byte) (i + 1); } for (byte i = 0; i < 30; i++) { restest8[i] = (byte) (i + 1); } var result2 = false; //passt var res5 = testmath.ZickZackScanByte(test5); var res6 = testmath.ZickZackScanByte(test6); var res7 = testmath.ZickZackScanByte(test7); var res8 = testmath.ZickZackScanByte(test8); if (res5.SequenceEqual(restest5) && res6.SequenceEqual(restest6) && res7.SequenceEqual(restest7) && res8.SequenceEqual(restest8)) { result2 = true; } if (result1 && result2) { return (true); } return (false); //Color example Color[] Colortest = new Color[10]; Color3 col3 = new Color3(); Color1 col1 = new Color1(); Colortest[1] = col3; Colortest[2] = col1; }
public void PPMtoJpg(string imageSrc, string imagedest) { Bitstream bs = new Bitstream(); PlainFormatReader pfr = new PlainFormatReader(imageSrc); Mathloc ml = new Mathloc(); Picture pic = pfr.ReadPicture(); int height = pic.Head.pixelMaxY; int width = pic.Head.pixelMaxX; Color3[,] col3 = new Color3[height,width]; byte[] colors = new byte[3]; //convert RGB to YUV for each pixel for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { col3[y, x] = pic.Data.PictureYX[y, x]; colors[0] = col3[y, x].a; // R colors[1] = col3[y, x].b; // G colors[2] = col3[y, x].c; // B colors = ml.RGBToYUV(colors); col3[y, x].a = colors[0]; // Y col3[y, x].b = colors[1]; // U col3[y, x].c = colors[2]; // V } } //convert float array to byte array float[,] yArray = new float[width, height]; // width and height vertauscht float[,] uArray = new float[width, height]; float[,] vArray = new float[width, height]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { yArray[i, j] = (float)col3[j, i].a; uArray[i, j] = (float)col3[j, i].b; vArray[i, j] = (float)col3[j, i].c; } } byte[,] yArrayEnde = new byte[width, height]; byte[,] uArrayEnde = new byte[width, height]; byte[,] vArrayEnde = new byte[width, height]; //get float [number of 8x8][8x8] var yarry = aufteilen(yArray); var uarry = aufteilen(uArray); var varry = aufteilen(vArray); //geht beim 40x40 bild 25 for (int y = 0; y < height/8; y ++) { for (int x = 0; x < width/8; x ++) { //DCTDirect for (int i = 0; i < ((height * width) / 64); i++) { yArray = DCT.DCTdirect(yarry[i]); uArray = DCT.DCTdirect(uarry[i]); vArray = DCT.DCTdirect(varry[i]); } //convert float array to byte array byte[,] yArrayB = new byte[width, height]; byte[,] uArrayB = new byte[width, height]; byte[,] vArrayB = new byte[width, height]; for (int i = 0; i < width/8; i++) { for (int j = 0; j < height/8; j++) { yArrayB[i, j] = (byte)yArray[i, j]; uArrayB[i, j] = (byte)uArray[i, j]; vArrayB[i, j] = (byte)vArray[i, j]; } } for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { yArrayEnde[i * x, j * y] = yArrayB[i, j]; uArrayEnde[i * x, j * y] = uArrayB[i, j]; vArrayEnde[i * x, j *y] = vArrayB[i, j]; } } byte[] yArrayB2 = new byte[64]; byte[] uArrayB2 = new byte[64]; byte[] vArrayB2 = new byte[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { yArrayB2[ZigZagTable2[i*j]] = yArrayB[i, j]; uArrayB2[ZigZagTable2[i*j]] = uArrayB[i, j]; vArrayB2[ZigZagTable2[i*j]] = vArrayB[i, j]; } } // Create Huffmantables //yArrayEnde = HuffmanCalc(YDCNodes, YDCValues, yArrayB2); //yArrayEnde = HuffmanCalc(YDCNodes, YACValues, yArrayB2); //uArrayEnde = HuffmanCalc(CbDCNodes, CbDCValues, uArrayB2); //uArrayEnde = HuffmanCalc(CbACNodes, CbACValues, uArrayB2); //vArrayEnde = HuffmanCalc(CbDCNodes, CbDCValues, vArrayB2); //vArrayEnde = HuffmanCalc(CbACNodes, CbACValues, vArrayB2); } } //create JPG head PictureHead.CreateJPGHead(bs, (ushort)height, (ushort)width); //TODO: DCT for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { bs.AddByte((byte)yArrayEnde[x, y]); bs.AddByte((byte)uArrayEnde[x, y]); bs.AddByte((byte)vArrayEnde[x, y]); } } bs.AddShort(0xffd9); //End of Picture Marker bs.WriteToFile(imagedest); }
public void Color3AdditionC(Color3 inputColor) { c += inputColor.c; }
//Bitmap test public void TestChannelResolutionReduction(string inputFile, string outputFile) { // load Bitmap .png Bitmap bitmap = new Bitmap(inputFile); Color[,] picture = new Color[bitmap.Height, bitmap.Width]; for (int x = 0; x < bitmap.Width; x++) { for (int y = 0; y < bitmap.Height; y++) { var bitmapPixel = bitmap.GetPixel(x, y); // sets RGB for each pixel Color3 newPixel = new Color3 { a = bitmapPixel.R, b = bitmapPixel.G, c = bitmapPixel.B }; picture[y, x] = newPixel; } } // CompressionHandler compressionHandler = new CompressionHandler(picture, bitmap.Width, bitmap.Height); // // compressionhandler dont neednead parameter yet // Color[,] result = compressionHandler.LocalAveraging444To422(0xDEAD); // Bitmap resultImage = new Bitmap(bitmap.Width, bitmap.Height); // for (int y = 0; y < bitmap.Height; y++) // { // for (int x = 0; x < bitmap.Width; x++) // { // // draws image // System.Drawing.Color color = System.Drawing.Color.FromArgb(result[y, x].a, result[y, x].b, result[y, x].c); // resultImage.SetPixel(x, y, color); // } // } // resultImage.Save(outputFile); }
public void Color3AdditionB(Color3 inputColor) { b += inputColor.b; }
public void Color3AdditionA(Color3 inputColor) { a += inputColor.a; }
public void Color3AdditionC(Color3 inputColor) { c += inputColor.c; }
public void Color3AdditionB(Color3 inputColor) { b += inputColor.b; }
public void Color3AdditionA(Color3 inputColor) { a += inputColor.a; }