/// <summary> /// Adds a photo to the current free place in the page /// </summary> /// <param name="photoPath">the path for the source photo</param> public void AddPhoto(string photoPath) { //If we exceeded the number of photos allowed in a page if (_numOfPhotos == Constants.NumberOfPhotosInAPage) { return; } //Load the photo from the hard disk using (var photo = Image.FromFile(photoPath)) { //Draw the image on the bitmap ImageManipulationUtils.DrawImageOnBitmap(_pageBitmap, photo, _currentColumn * Constants.ScaledWidth, _currentLine * Constants.ScaledHeight); #region Update the class counters //Update the current column (0 or 1) _currentColumn = (_currentColumn + 1) % 2; //If the column is zero we need to change line if (_currentColumn == 0) { _currentLine++; } //Increment the number of photos _numOfPhotos++; #endregion } }
/// <summary> /// Merge all the photos in the photo list with the specified frame and save them to the temp folder /// </summary> private void MergePhotosWithFrame(UiPageList pageList) { foreach (var photo in pageList.GetPages().SelectMany(page => page)) { //Merge the photo to the frame using (Image img = Image.FromFile(photo.PicturePath), frameImg = Image.FromFile(_framePath)) { var outputImage = ImageManipulationUtils.MergePhotoAndFrame(img, frameImg); //Save the merged image to the hard drive the number of times specified by the user for (var i = 0; i < photo.NumberOfTimes; i++) { //Create the merged photo path var mergedPhotoTempPath = Constants.TempMergedFilesFolder + Path.GetFileNameWithoutExtension(photo.PicturePath) + "_" + i + Constants.OutputFileType; //Create the temp directory Directory.CreateDirectory(Constants.TempMergedFilesFolder); //Save the merged photo outputImage.Save(mergedPhotoTempPath, ImageFormat.Jpeg); } } } }