/// <summary> /// Inserts an BBImage into this BBImage. /// </summary> /// <param name="insertImage">The BBImage that will be inserted into this BBImage.</param> /// <param name="x">The place where the image will be inserted.</param> /// <param name="y">The place where the image will be inserted.</param> /// <returns>True upon completion</returns> public bool Insert(BarebonesImage insertImage, int x, int y) { /* Loop through all the pixles in the image to be inserted. * Offset it vertically so it ends up in the right position*/ for (int i = 0; i < insertImage.Width; i++) { for (int j = 0; j < insertImage.Height; j++) { SetPixel(i + x, j + y, insertImage.GetPixel(i, j)); } } return(true); }
/// <summary> /// Samples an area of the four BarebonesImages and calculates how many percent of the pixels are black. /// </summary> /// <param name="x">The width position to start the sampling at.</param> /// <param name="y">The highth position to start the sampling at.</param> /// <param name="sampleArea">How large an area to sample over.</param> /// <returns>The sampled CMYK values as a struct.</returns> public CMYKvalues TotalAreaCoverageSampler(int x, int y, int sampleArea) { CMYKvalues sampleValues = new CMYKvalues(); //Loops through all the pixels and count the ones. for (int i = 0; i < sampleArea; i++) { for (int j = 0; i < sampleArea; i++) { if (cyan.GetPixel(x + i, y + j)) { sampleValues.C += 1; } if (magenta.GetPixel(x + i, y + j)) { sampleValues.M += 1; } if (yellow.GetPixel(x + i, y + j)) { sampleValues.Y += 1; } if (black.GetPixel(x + i, y + j)) { sampleValues.K += 1; } } } //Divide the number of black pixels with the area size. sampleValues.C = sampleValues.C / sampleArea; sampleValues.M = sampleValues.M / sampleArea; sampleValues.Y = sampleValues.Y / sampleArea; sampleValues.K = sampleValues.K / sampleArea; return(sampleValues); }