الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف - طلب حل : ]تكفوون اشرحو لي هالاكواد ضروري مرررة مطلوبة بكرة

مغلق
بدأه alkasser990 في 1 يونيو 2008 · 1 رد · 513 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

كيفكم.........

ياشباااب البرمجة يالليت احد يشرحلي عمل كل سطر في البرنامج هذاا

هوو مشروع طالبه منا الدكتوور وجبناه باكثر من طريقة وبكره رااح ينااقشنا فيه

ياليت تسااعدوووني تكفوون

هو بالكنسل ابلكيشن (Console application)

والبرنامج عبارة عن معالجة للصور وتغيير قيم البكسل تبعهاا ونستخدم فيه المينو سترب والبكتشر بوكس بس

تكفوون ياليت اللي فااهم الأكوواد هذي اش تسوي يشرحهاا لي تكفوون

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication3
{
	public partial class Form1 : Form
	{
		int[,] pix_arry = new int[512, 512];
		System.Drawing.Bitmap flag = new System.Drawing.Bitmap(512, 512);
		public Form1()
		{
			InitializeComponent();
		}

		private void fileToolStripMenuItem_Click(object sender, EventArgs e)
		{

		}

		private void loadImageToolStripMenuItem_Click(object sender, EventArgs e)
		{
			openFileDialog1.ShowDialog();
			pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);

		}

		private void rampToolStripMenuItem_Click(object sender, EventArgs e)
		{

for (int i = 0; i < 256; i++)
{
for (int j = 0; j < 256; j++)
{
pix_arry[i, j] = j;
flag.SetPixel(j, i, Color.FromArgb(pix_arry[i, j], pix_arry[i, j], pix_arry[i, j]));
}
}
pictureBox1.Image = flag;
		}

		private void circleToolStripMenuItem_Click(object sender, EventArgs e)
		{

			int r;
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{

					r = (int)(Math.Sqrt((i - 128) * (i - 128) + (j - 128) * (j - 128))); if (r < 80)
						pix_arry[i, j] = 255;
					else
						pix_arry[i, j] = 0;

					flag.SetPixel(j, i, Color.FromArgb(pix_arry[i, j], pix_arry[i, j], pix_arry[i, j]));
				}
			}
			pictureBox1.Image = flag;
		}

		private void squareToolStripMenuItem_Click(object sender, EventArgs e)
		{

for (int i = 0; i < 256; i++)
{
for (int j = 0; j < 256; j++)
{
if ((i > 64 && i < 192) && (j > 64 && j < 192))
pix_arry[i, j] = 255;
else
pix_arry[i, j] = 0;

flag.SetPixel(j, i, Color.FromArgb(pix_arry[i, j], pix_arry[i, j], pix_arry[i, j]));
}
}
pictureBox1.Image = flag;
		}

		private void rectangleToolStripMenuItem_Click(object sender, EventArgs e)
		{

			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					if ((i > 80 && i < 202) && (j > 54 && j < 222))
						pix_arry[i, j] = 255;
					else
						pix_arry[i, j] = 0;

					flag.SetPixel(j, i, Color.FromArgb(pix_arry[i, j], pix_arry[i, j], pix_arry[i, j]));
				}
			}
			pictureBox1.Image = flag;
		}

		private void randomToolStripMenuItem_Click(object sender, EventArgs e)
		{

Random rnd = new Random();
for (int i = 0; i < 256; i++)
{
for (int j = 0; j < 256; j++)
{
pix_arry[i, j] = rnd.Next(0, 255);
flag.SetPixel(j, i, Color.FromArgb(pix_arry[i, j], pix_arry[i, j], pix_arry[i, j]));
}
}
pictureBox1.Image = flag;
		}

		private void clockWiseToolStripMenuItem_Click(object sender, EventArgs e)
		{

Bitmap ff = new Bitmap(pictureBox1.Image);
Bitmap d = new Bitmap(ff.Height, ff.Width);

for (int x = 0; x < ff.Height; x++)
for (int y = 0; y < ff.Width; y++)
{
Color c = ff.GetPixel(x, y);

d.SetPixel((ff.Height - 1) - y, x, c);

}
pictureBox1.Image = d;
		}

		private void countWiseToolStripMenuItem_Click(object sender, EventArgs e)
		{

Bitmap ff = new Bitmap(pictureBox1.Image);
Bitmap d = new Bitmap(ff.Height, ff.Width);

for (int x = 0; x < ff.Height; x++)
for (int y = 0; y < ff.Width; y++)
{
Color c = ff.GetPixel(x, y);

d.SetPixel(y, (ff.Height - 1) - x, c);

}
pictureBox1.Image = d;
		}

		private void zoomInToolStripMenuItem_Click(object sender, EventArgs e)
		{

Bitmap ff = new Bitmap(pictureBox1.Image);
Bitmap d = new Bitmap(ff.Height * 2, ff.Width * 2);

for (int x = 0; x < d.Height; x++)
for (int y = 0; y < d.Width; y++)
{
Color c;

if (x % 2 == 0 || y % 2 == 0 || x == 0 || y == 0)
{
c = ff.GetPixel(y / 2, x / 2);
d.SetPixel(y, x, c);
}
else if (x % 2 != 0 || y % 2 != 0)
{
c = ff.GetPixel((y / 2), (x / 2));
d.SetPixel(y, x, c);
}
}
pictureBox1.Image = d;
		}

		private void zoomOutToolStripMenuItem_Click(object sender, EventArgs e)
		{


Bitmap ff = new Bitmap(pictureBox1.Image);
Bitmap d = new Bitmap(ff.Height / 2, ff.Width / 2);

for (int x = 0; x < ff.Height; x++)
for (int y = 0; y < ff.Width; y++)
{
Color c = ff.GetPixel(y, x);

if (x % 2 == 0 || y % 2 == 0 || x == 0 || y == 0)
{
int i = x / 2;
int j = y / 2;

d.SetPixel(j, i, c);
}
}

pictureBox1.Image = d;
		}

		private void gammaCorectionToolStripMenuItem_Click(object sender, EventArgs e)
		{

			Bitmap ff = new Bitmap(pictureBox1.Image);
			int[,] inputimage = new int[255, 255];
			int g;

			int gamma = 2;
			for (int i = 0; i < ff.Height; i++)
				for (int j = 0; j < ff.Width; j++)
				{
					Color c = ff.GetPixel(j, i);
					int x = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);


					g = (int)(255 * Math.Pow((x / 255.0), gamma));
					ff.SetPixel(j, i, Color.FromArgb(g, g, g));
				}
			pictureBox1.Image = ff;
		}

		private void brightressToolStripMenuItem_Click(object sender, EventArgs e)
		{

Bitmap b1 = new Bitmap(pictureBox1.Image);
int[,] x1 = new int[b1.Height, b1.Width];
int[,] x2 = new int[b1.Height, b1.Width];
int g1 = x1[0, 0];
int g2 = x1[0, 0];
int f1 = x1[0, 0];
int f2 = x1[0, 0];
double a = 1.5;
double b = 30;

for (int i = 0; i < b1.Height; i++)
{
for (int j = 0; j < b1.Width; j++)
{
Color c = b1.GetPixel(j, i);
x1[i, j] = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
x2[i, j] = (int)(a * x1[i, j] + b);

if (x1[i, j] > g2)
g2 = x1[i, j];

if (x1[i, j] < g1)
g1 = x1[i, j];

if (x2[i, j] > f2)
f2 = x1[i, j];

if (x2[i, j] < f1)
f1 = x1[i, j];
}
}
for (int i = 0; i < b1.Height; i++)
{
for (int j = 0; j < b1.Width; j++)
{
x2[i, j] = g1 + ((g2 - g1) / (f2 - f1)) * (x1[i, j] - f1);

if (x2[i, j] > 255)
x2[i, j] = 255;

b1.SetPixel(j, i, Color.FromArgb(x2[i, j], x2[i, j], x2[i, j]));
}
}
pictureBox1.Image = b1;
		}

		private void averageToolStripMenuItem_Click(object sender, EventArgs e)
		{

			Bitmap b1 = new Bitmap(pictureBox1.Image);
			Bitmap b2 = new Bitmap(pictureBox1.Image);
			int[,] Pix_Array = new int[b1.Height, b1.Width];
			int sum;
			int Avg;

			for (int i = 0; i < b1.Height; i++)
			{
				for (int j = 0; j < b1.Width; j++)
				{
					Color c = b1.GetPixel(j, i);
					Pix_Array[i, j] = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
				}
			}


			for (int i = 1; i < b1.Height - 1; i++)
			{
				for (int j = 1; j < b1.Width - 1; j++)
				{


					sum = 0;
					for (int x = -1; x <= 1; x++)
					{
						for (int y = -1; y <= 1; y++)
						{
							sum += Pix_Array[i + x, j + y];
						}
					}

					Avg = (int)(sum / 9);

					b2.SetPixel(j, i, Color.FromArgb(Avg, Avg, Avg));

				}
			}

			pictureBox1.Image = b2;
		}


				}
		}
#2

تأسف إدارة الفريق العربي لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة طلب حل الواجبات والتمارين وأعمال السنة.

قواعد طرح المشاركات

/index.php?showtopic=29343

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…