/// <summary> /// Modifies the brightness of the given file. /// </summary> /// <param name="dblAffect">>How to modify. Value of 1 leaves alone, 0.x darkens, 1.x is to lightens.</param> /// <param name="originalPathFile">Source file, could be the same as the change file.</param> /// <param name="changeImagePathFile">The file to receive the change.</param> /// <returns>True for success.</returns> public bool Brightness(double brightValue, string originalPathFile, string changeImagePathFile) { bool bRet = false; if (null == originalPathFile) return false; if (null == changeImagePathFile) return false; if (originalPathFile.Length > 0) // may have been set at creation, so not given m_originalFile = originalPathFile; // Fix slashes - never trust that they have done this. m_originalFile = m_originalFile.Replace('/', '\\').Replace("\\\\", "\\"); changeImagePathFile = changeImagePathFile.Replace('/', '\\').Replace("\\\\", "\\"); // use cximage library instead of .Net code if (m_originalFile != changeImagePathFile) { // copy file to new if needed StorageClient.Context.File.Copy(m_originalFile, changeImagePathFile, true); MakeWriteable(changeImagePathFile); // in case the original was readonly } if (brightValue != 1.0) { ImageGalleryInterop.CImageResizerClass ig = new ImageGalleryInterop.CImageResizerClass(); ig.BrightenImageFile(changeImagePathFile, brightValue); } /* System.Drawing.Image img = System.Drawing.Image.FromFile(m_originalFile); Bitmap bmpImage = new Bitmap(img); img.Dispose(); // Free up the file for changes Color pixel; int r, g, b; for (int y = 0; y < bmpImage.Height; y++) { for (int x = 0; x < bmpImage.Width; x++) { pixel = bmpImage.GetPixel(x, y); r = (int)((double)pixel.R * brightValue); if (r < 0) r = 0; if (r > 255) r = 255; g = (int)((double)pixel.G * brightValue); if (g < 0) g = 0; if (g > 255) g = 255; b = (int)((double)pixel.B * brightValue); if (b < 0) b = 0; if (b > 255) b = 255; bmpImage.SetPixel(x, y, Color.FromArgb(r, g, b)); } } bmpImage.Save(changeImagePathFile); // Save for convenient use. m_width = bmpImage.Width; m_height = bmpImage.Height; bmpImage.Dispose(); */ m_localResultFile = changeImagePathFile; bRet = true; return bRet; }