public static WatermarkProperties getInstance() { if (_WatermarkProperties_inst == null) { _WatermarkProperties_inst = new WatermarkProperties(); } return(_WatermarkProperties_inst); }
// // Summary: // Applies watermark on the filtered frame. // // Parameters: // Sourcefile path to apply watermark. // public static void ApplyWatermark(string sourcePath) { DSLR_Tool_PC.ViewModels.Watermark waterMarkProperties = DSLR_Tool_PC.ViewModels.Watermark.GetInstance(); Bitmap wImage = new Bitmap(waterMarkProperties.ImagePath); //Bitmap watermarkImage = new Bitmap(wImage, waterMarkProperties.ImageWidth, waterMarkProperties.ImageHeight); Bitmap image = new Bitmap(sourcePath); //Adjust size of watermark image// Bitmap watermarkImage = new Bitmap(WatermarkProperties.getInstance().WatermarkResolutionCorrection(wImage, image)); //Opacity correcting of watermark if (waterMarkProperties.IsOpacityApply) { watermarkImage = SetOpacity(watermarkImage, (float)waterMarkProperties.ImageOpacity1); } //Correction for x and y co-ordinate of watermark on final image. WatermarkProperties.getInstance().XandYcorrection(); //store watermark on the final image Bitmap Finalimage = new Bitmap(WatermarkProperties.getInstance().WatermarkImage(image, watermarkImage, WatermarkProperties.getInstance().x_location, WatermarkProperties.getInstance().y_location)); image.Dispose(); image = null; string dst = sourcePath; if (File.Exists(sourcePath)) { File.Delete(sourcePath); } StaticClass.saveBitmap2File(Finalimage, dst); wImage.Dispose(); Finalimage.Dispose(); watermarkImage.Dispose(); GC.Collect(); Thread.Sleep(10); }