Skip to content

Commit 951c7e7

Browse files
committed
v1.0.0
1 parent c5d575c commit 951c7e7

File tree

17 files changed

+156
-21
lines changed

17 files changed

+156
-21
lines changed

.vs/qpv-blur/v16/.suo

-4 KB
Binary file not shown.
8 KB
Binary file not shown.
-32 KB
Binary file not shown.
-3.95 MB
Binary file not shown.

qpv-blur/BlurRegionForm.Designer.cs

Lines changed: 75 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qpv-blur/BlurRegionForm.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,30 @@ public BlurRegionForm(Bitmap bmp)
1212
{
1313
originalImage = bmp;
1414
InitializeComponent();
15+
1516
radiusSlider.Value = Properties.Settings.Default.Radius;
17+
typeComboBox.SelectedIndex = Properties.Settings.Default.Type;
18+
1619
pictureBox1.Image = bmp;
1720
}
1821

1922
private void previewBtn_Click(object sender, EventArgs e)
2023
{
21-
pictureBox1.Image = Main.ProcessBlur(originalImage, new Rectangle(0, 0, originalImage.Width, originalImage.Height), radiusSlider.Value);
24+
if (typeComboBox.SelectedIndex == 0)
25+
{
26+
pictureBox1.Image = Main.ProcessBlur(originalImage, new Rectangle(0, 0, originalImage.Width, originalImage.Height), radiusSlider.Value);
27+
}
28+
else
29+
{
30+
pictureBox1.Image = Main.ProcessPixelate(originalImage, new Rectangle(0, 0, originalImage.Width, originalImage.Height), radiusSlider.Value);
31+
}
2232
}
2333

2434
private void saveBtn_Click(object sender, EventArgs e)
2535
{
2636
Properties.Settings.Default.Radius = radiusSlider.Value;
37+
Properties.Settings.Default.Type = typeComboBox.SelectedIndex;
38+
2739
Properties.Settings.Default.Save();
2840
this.Close();
2941
}

qpv-blur/Main.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ public Bitmap blur(Bitmap bmp, string path)
1616
}
1717
else
1818
{
19-
return Main.ProcessBlur(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), Properties.Settings.Default.Radius);
19+
if (Properties.Settings.Default.Type == 0)
20+
{
21+
return Main.ProcessBlur(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), Properties.Settings.Default.Radius);
22+
}
23+
else
24+
{
25+
return Main.ProcessPixelate(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), Properties.Settings.Default.Radius);
26+
}
2027
}
2128
}
2229

@@ -98,5 +105,39 @@ public unsafe static Bitmap ProcessBlur(Bitmap image, Rectangle rectangle, Int32
98105

99106
return blurred;
100107
}
108+
109+
public static Bitmap ProcessPixelate(Bitmap image, Rectangle rectangle, Int32 pixelateSize)
110+
{
111+
Bitmap pixelated = new Bitmap(image.Width, image.Height);
112+
113+
// make an exact copy of the bitmap provided
114+
using (Graphics graphics = System.Drawing.Graphics.FromImage(pixelated))
115+
graphics.DrawImage(image, new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
116+
new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
117+
118+
// look at every pixel in the rectangle while making sure we're within the image bounds
119+
for (Int32 xx = rectangle.X; xx < rectangle.X + rectangle.Width && xx < image.Width; xx += pixelateSize)
120+
{
121+
for (Int32 yy = rectangle.Y; yy < rectangle.Y + rectangle.Height && yy < image.Height; yy += pixelateSize)
122+
{
123+
Int32 offsetX = pixelateSize / 2;
124+
Int32 offsetY = pixelateSize / 2;
125+
126+
// make sure that the offset is within the boundry of the image
127+
while (xx + offsetX >= image.Width) offsetX--;
128+
while (yy + offsetY >= image.Height) offsetY--;
129+
130+
// get the pixel color in the center of the soon to be pixelated area
131+
Color pixel = pixelated.GetPixel(xx + offsetX, yy + offsetY);
132+
133+
// for each pixel in the pixelate size, set it to the center color
134+
for (Int32 x = xx; x < xx + pixelateSize && x < image.Width; x++)
135+
for (Int32 y = yy; y < yy + pixelateSize && y < image.Height; y++)
136+
pixelated.SetPixel(x, y, pixel);
137+
}
138+
}
139+
140+
return pixelated;
141+
}
101142
}
102143
}

qpv-blur/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qpv-blur/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
<Setting Name="Radius" Type="System.Int32" Scope="User">
66
<Value Profile="(Default)">5</Value>
77
</Setting>
8+
<Setting Name="Type" Type="System.Int32" Scope="User">
9+
<Value Profile="(Default)">0</Value>
10+
</Setting>
811
</Settings>
912
</SettingsFile>

qpv-blur/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<setting name="Radius" serializeAs="String">
1111
<value>5</value>
1212
</setting>
13+
<setting name="Type" serializeAs="String">
14+
<value>0</value>
15+
</setting>
1316
</qpv_blur.Properties.Settings>
1417
</userSettings>
1518
</configuration>

0 commit comments

Comments
 (0)