- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
-
- namespace PhotoCraft
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private void browseButton_Click(object sender, EventArgs e)
- {
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- pictureBox1.Load(openFileDialog1.FileName);
-
- }
-
- private void pictureBox2_Click(object sender, EventArgs e)
- {
-
- }
-
- private void craftButton_Click(object sender, EventArgs e)
- {
- Image UserPic;
- UserPic = pictureBox1.Image;
- pictureBox2.Image = UserPic;
- }
- public void GenerateThumbnail(string filePath, string origFileName, string thumbFileName, ImageFormat imgFormat)
- {
-
- System.Drawing.Image origImage = System.Drawing.Image.FromFile(filePath + @"\" + origFileName);
-
- float WidthPer, HeightPer;
- int NewWidth, NewHeight;
- Size ThumbnailSize = new Size(100, 100);
- if (origImage.Width > origImage.Height)
- {
- NewWidth = ThumbnailSize.Width;
- WidthPer = (float)ThumbnailSize.Width / origImage.Width;
- NewHeight = Convert.ToInt32(origImage.Height * WidthPer);
- }
- else
- {
- NewHeight = ThumbnailSize.Height;
- HeightPer = (float)ThumbnailSize.Height / origImage.Height;
- NewWidth = Convert.ToInt32(origImage.Width * HeightPer);
- }
- System.Drawing.Image origThumbnail = new Bitmap(NewWidth, NewHeight, origImage.PixelFormat);
- Graphics oGraphic = Graphics.FromImage(origThumbnail);
- oGraphic.CompositingQuality = CompositingQuality.HighQuality;
- oGraphic.SmoothingMode = SmoothingMode.HighQuality;
- oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
- Rectangle oRectangle = new Rectangle(0, 0, NewWidth, NewHeight);
- oGraphic.DrawImage(origImage, oRectangle);
- origThumbnail.Save(filePath + @"\" + thumbFileName, imgFormat);
- origImage.Dispose();
- }
-
- private void MaintainAspectRatioButton_CheckedChanged(object sender, EventArgs e)
- {
-
- }
-
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox1.checked)
-
- //Vedligehold Aspect-Ratio
- pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
- else
- //Gå tilbage til fyld hele boksen.
- pictureBox1.Sizemode = PictureBoxSizeMode.StretchImage;
- }
-
- }
-
-
-
-
- }
Det er vist det. GenerateThumbnail er min gamle "Resize'er" den skal vel sikkert fjernes nu eller hvad?