private void setSecondPixel(Color pixelColor, byte[] imageWithHeader) { if (this.EncryptionType == EncryptionType.Encrypted) { pixelColor.R |= 1; } else { pixelColor.R &= 0xfe; } if (this.FileType == FileType.Text) { pixelColor.B |= 1; } else { pixelColor.B &= 0xfe; } pixelColor.G = (byte)this.Bpcc; PixelUtilities.SetPixelBgra8(imageWithHeader, ImageConstants.FirstX, ImageConstants.SecondX, pixelColor, this.sourcePicture.Width, this.sourcePicture.Height); }
private void setPixelWhite(int j, int i) { var sourcePixelColor = Color.FromArgb(this.maxRgbValue, this.maxRgbValue, this.maxRgbValue, this.maxRgbValue); PixelUtilities.SetPixelBgra8(this.sourcePicture.Pixels, j, i, sourcePixelColor, this.sourcePicture.Width, this.sourcePicture.Height); }
private void setPixelBlack(byte[] pixels, int i, int j) { var sourcePixelColor = Color.FromArgb(this.maxRgbValue, this.minRgbValue, this.minRgbValue, this.minRgbValue); PixelUtilities.SetPixelBgra8(pixels, i, j, sourcePixelColor, this.sourcePicture.Width, this.sourcePicture.Height); }
private void setFirstPixel(Color pixelColor, byte[] imageWithHeader) { pixelColor.R = (byte)ImageConstants.HiddenMessageValue; pixelColor.G = (byte)ImageConstants.HiddenMessageValue; pixelColor.B = (byte)ImageConstants.HiddenMessageValue; PixelUtilities.SetPixelBgra8(imageWithHeader, ImageConstants.FirstX, ImageConstants.FirstX, pixelColor, this.sourcePicture.Width, this.sourcePicture.Height); }
private int updatePixel(IReadOnlyList <byte> bytes, int i, int j, int index) { var sourcePixelColor = PixelUtilities.GetPixelBgra8(this.sourcePicture.Pixels, i, j, this.sourcePicture.Width, this.sourcePicture.Height); sourcePixelColor.R = bytes[index]; index++; sourcePixelColor.G = bytes[index]; index++; sourcePixelColor.B = bytes[index]; index++; PixelUtilities.SetPixelBgra8(this.sourcePicture.Pixels, i, j, sourcePixelColor, this.sourcePicture.Width, this.sourcePicture.Height); return(index); }
/// <summary> /// Decrypts the picture. /// </summary> /// <param name="extractedImage">The extracted image.</param> public static void DecryptPicture(Picture extractedImage) { for (var i = 0; i < extractedImage.Height / 2; i++) { for (var j = 0; j < extractedImage.Width; j++) { var currentIndex = i; var oppositeYValue = (int)(currentIndex + extractedImage.VerticalCenter); var oppositePixelColor = PixelUtilities.GetPixelBgra8(extractedImage.Pixels, oppositeYValue, j, extractedImage.Width, extractedImage.Height); var pixelColor = PixelUtilities.GetPixelBgra8(extractedImage.Pixels, i, j, extractedImage.Width, extractedImage.Height); PixelUtilities.SetPixelBgra8(extractedImage.Pixels, i, j, oppositePixelColor, extractedImage.Width, extractedImage.Height); PixelUtilities.SetPixelBgra8(extractedImage.Pixels, oppositeYValue, j, pixelColor, extractedImage.Width, extractedImage.Height); } } }
private void setPixelToClosestQuantizedColor(List <QuantizedColor> colors, Color sourcePixelColor, double distance, int j, int i) { foreach (var quantizedColor in colors) { var color = quantizedColor.Color; var curDist = Math.Pow(color.R - sourcePixelColor.R, 2) + Math.Pow(color.G - sourcePixelColor.G, 2) + Math.Pow(color.B - sourcePixelColor.B, 2); if (curDist < distance) { distance = curDist; var newPixelColor = Color.FromArgb(255, color.R, color.G, color.B); PixelUtilities.SetPixelBgra8(this.sourcePicture.Pixels, j, i, newPixelColor, this.sourcePicture.Width, this.sourcePicture.Height); } } }
/// <summary> /// Applies the grayscale filter. /// </summary> public void applyGrayscaleFilter() { for (var i = 0; i < this.sourcePicture.Width - 1; i++) { for (var j = 0; j < this.sourcePicture.Height - 1; j++) { var sourcePixelColor = PixelUtilities.GetPixelBgra8(this.sourcePicture.Pixels, j, i, this.sourcePicture.Width, this.sourcePicture.Height); var averageColor = (sourcePixelColor.R + sourcePixelColor.G + sourcePixelColor.B) / ImageConstants.ColorChannelCount; var averageColorByte = Convert.ToByte(averageColor); var newPixelColor = Color.FromArgb(this.maxRgbValue, averageColorByte, averageColorByte, averageColorByte); PixelUtilities.SetPixelBgra8(this.sourcePicture.Pixels, j, i, newPixelColor, this.sourcePicture.Width, this.sourcePicture.Height); } } this.sourcePicture.ModifiedImage = new WriteableBitmap((int)this.sourcePicture.Width, (int)this.sourcePicture.Height); }
private static void embedBlackPixel(byte[] pixels, Color sourcePixelColor, int i, int j, Picture sourcePicture) { sourcePixelColor.B = (byte)(sourcePixelColor.B & ~1); PixelUtilities.SetPixelBgra8(pixels, i, j, sourcePixelColor, sourcePicture.Width, sourcePicture.Height); }
private static void embedWhitePixel(byte[] pixels, Color sourcePixelColor, int i, int j, Picture sourcePicture) { sourcePixelColor.B |= 1; PixelUtilities.SetPixelBgra8(pixels, i, j, sourcePixelColor, sourcePicture.Width, sourcePicture.Height); }