• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

C Sharp Uygulamalar Grafik Olarak Çizilen Resimin Piksel Değerlerini Bulma

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private **** Form1_Load(object sender, EventArgs e)
        {

            Bitmap bmp = new Bitmap(360, 360);

            Graphics gr = Graphics.FromImage(bmp);

            Rectangle rect = new System.Drawing.Rectangle(0, 0, 360, 360);
            gr.FillRectangle(System.Drawing.Brushes.Blue, rect);

            // Create pens.
            Pen redPen = new Pen(Color.Red, 3);
            Pen greenPen = new Pen(Color.Green, 3);

            // Create points that define curve.
            Point point1 = new Point(50, 50);
            Point point2 = new Point(100, 25);
            Point point3 = new Point(200, 5);
            Point point4 = new Point(250, 50);
            Point point5 = new Point(300, 100);
            Point point6 = new Point(350, 200);
            Point point7 = new Point(250, 250);
            Point[] curvePoints = { point1, point2, point3, point4, point5, point6, point7 };

            // Draw lines between original points to screen.
            gr.DrawLines(redPen, curvePoints);

            List points = new List();

            for (int y = 0; y < bmp.Height; ++y)
            {
                for (int x = 0; x < bmp.Width; ++x)
                {
                    Color c = bmp.GetPixel(x, y);
                    if (c.ToArgb() == Color.Red.ToArgb())
                    {
                        points.Add(new Point(x, y));
                    }
                }
            }

            //  MessageBox.Show(points[0].ToString());

            pictureBox1.Image = bmp;
            //    bmp.Dispose();

            for (int i = 0; i < points.Count; i++)
            {
                listBox1.Items.Add(points[i].ToString());
            }
 
        }
 
    }
}
 
Üst