ImageZoom.sln
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageZoom", "ImageZoom\ImageZoom.csproj", "{583EC0A2-1571-43B5-B44D-41349BCAA8E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{583EC0A2-1571-43B5-B44D-41349BCAA8E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{583EC0A2-1571-43B5-B44D-41349BCAA8E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{583EC0A2-1571-43B5-B44D-41349BCAA8E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{583EC0A2-1571-43B5-B44D-41349BCAA8E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {99B4A390-89D4-4F15-9B40-8049BFC83196}
EndGlobalSection
EndGlobal
ImageZoom/App.config
ImageZoom/ImageZoom.csproj
Debug
AnyCPU
{583EC0A2-1571-43B5-B44D-41349BCAA8E4}
WinExe
ImageZoom
ImageZoom
v4.6.1
512
true
true
AnyCPU
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
AnyCPU
pdbonly
true
bin\Release\
TRACE
prompt
4
Form
MainForm.cs
MainForm.cs
ResXFileCodeGenerator
Resources.Designer.cs
Designer
True
Resources.resx
SettingsSingleFileGenerator
Settings.Designer.cs
True
Settings.settings
True
ImageZoom/MainForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ImageZoom
{
public partial class MainForm : Form
{
private string imgPath = "sampe.jpg";
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
imgTextBox.Text = imgPath;
}
private void doButton_Click(object sender, EventArgs e)
{
if(string.IsNullOrWhiteSpace(imgPath))
{
MessageBox.Show("You can't go without open an Image.");
return;
}
try
{
Bitmap bitmap = (Bitmap)Bitmap.FromFile(imgPath);
orgPictureBox.Image = bitmap;
var orgWidth = bitmap.Width;
var orgHeight = bitmap.Height;
var scale = scale2XRadioButton.Checked ? 2 : 4;
var newWidth = scale * orgWidth;
var newHeight = scale * orgHeight;
double ratio = 1.0 / scale;
Func
getSource = (i,j) => {
if (i < 0)
i = 0;
if (j < 0)
j = 0;
if (i >= orgWidth)
i = orgWidth - 1;
if (j >= orgHeight)
j = orgHeight - 1;
return bitmap.GetPixel(i, j).ToArgb();
};
Bitmap newMap = new Bitmap(newWidth, newHeight);
for(int xd=0;xd< newWidth; xd++)
{
for(int yd=0;yd {
var color = SincInterpolation.GetDestColor(xd, yd, ratio, getSource);
newMap.SetPixel(xd, yd, color);
}
}
scaledPictureBox.Image = newMap;
}
catch (System.IO.FileNotFoundException ex)
{
MessageBox.Show("File:" + ex.FileName + " Not Found.");
}
}
private int Rgb2Int(Color c)
{
int r = c.R;
int g = c.G;
int b = c.B;
return r << 16 + g << 8 + b;
}
private Color Int2Rgb(int rgb)
{
byte b = (byte)rgb;
byte g = (byte)(rgb >> 8);
byte r = (byte)(rgb >> 16);
var c = Color.FromArgb(r, g, b);
return c;
}
private void browseButton_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Image files(*.jpg;*.bmp;*.gif;*.png)|*.jpg;*.bmp;*.gif;*.png|All files(*.*)|*.*";
if(dlg.ShowDialog()==DialogResult.OK)
{
imgPath = dlg.FileName;
imgTextBox.Text = dlg.FileName;
}
}
}
}
ImageZoom/MainForm.Designer.cs
namespace ImageZoom
{
partial class MainForm
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.orgLable = new System.Windows.Forms.Label();
this.scaledPictureBox = new System.Windows.Forms.PictureBox();
this.orgPictureBox = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.doButton = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.scale4xRadioButton = new System.Windows.Forms.RadioButton();
this.scale2XRadioButton = new System.Windows.Forms.RadioButton();
this.browseButton = new System.Windows.Forms.Button();
this.imgTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.scaledPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.orgPictureBox)).BeginInit();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.orgLable);
this.panel1.Controls.Add(this.scaledPictureBox);
this.panel1.Controls.Add(this.orgPictureBox);
this.panel1.Dock =...