Solved

processing image with c# form

Posted on 2006-11-26
1
1,814 Views
Last Modified: 2008-03-04
hi experts
iam working on c#  project-<windows application> - (operations on image such zoom,invert..).

and i want codes for:
 zoom image in ,
 save image as ,
 undo for 3 times,
 smooth matrix,


 //note: i had  written this code:

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

namespace WindowsApplication5
{
    public partial class Form1 : Form
    {
        Bitmap borg;
        Bitmap binv;
        Bitmap bgrey;
        Bitmap bbri;






        #region onpaint
        protected override void  OnPaint(PaintEventArgs e)
        {
           if (borg!=null){
               e.Graphics.DrawImage(borg, ClientRectangle);


            }
            if (binv != null)
            {
                e.Graphics.DrawImage(binv, ClientRectangle);


            }
            if (bgrey != null) {
                e.Graphics.DrawImage(bgrey,ClientRectangle);
            }

            if (bbri != null) {
                e.Graphics.DrawImage(bbri, ClientRectangle);
           
            }
        }
#endregion onpaint

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK) {
                borg = new Bitmap(ofd.FileName);
               
                this.AutoScrollMinSize = borg.Size;
                Refresh();
           
           
            }

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void limToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //invert color
            binv = new Bitmap(borg.Width, borg.Height);
            for(int x=0;x<borg.Width;x++)
                for (int y = 0; y < borg.Height; y++) {
                    Color c = borg.GetPixel(x, y);

                    int r = c.R;
                    int g = c.G;
                    int b = c.B;


                    r = 255 - r;
                    g = 255 - g;
                    r = 255 - b;


             if (r > 255) r = 255; if (r < 0) r = 0;
             if (g > 255) g = 255; if (g < 0) g = 0;
             if (b > 255) b = 255; if (b < 0) b = 0;

                       
                Color cnew=Color.FromArgb(r,g,b) ;
                binv.SetPixel(x, y, cnew);




               
               
                }
                 Refresh();
           }



        private void invertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //grey color


            bgrey = new Bitmap(borg.Width, borg.Height);
            for (int x = 0; x < borg.Width; x++)
                for (int y = 0; y < borg.Height; y++)
                {
                    Color c = borg.GetPixel(x, y);

                    int l = (int)(0.3 * c.R + 0.49 * c.G + 0.11 * c.G);
                    Color cnew = Color.FromArgb(l, l, l);
                    bgrey.SetPixel(x, y, cnew);



                }
            Refresh();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
                        Refresh();


        }

        private void trackBar1_Scroll_1(object sender, EventArgs e)
        {
            bbri = new Bitmap(borg.Width, borg.Height);
            for (int x = 0; x < borg.Width; x++)
                for (int y = 0; y < borg.Height; y++)
                {
                    Color c = borg.GetPixel(x, y);

                    int r = c.R + brtrack.Value;
                    int g = c.G + brtrack.Value;
                    int b = c.B + brtrack.Value;



                    if (r > 255) r = 255; if (r < 0) r = 0;
                    if (g > 255) g = 255; if (g < 0) g = 0;
                    if (b > 255) b = 255; if (b < 0) b = 0;


                    Color cnew = Color.FromArgb(r, g, b);
                    bbri.SetPixel(x, y, cnew);


                }
            Refresh();

        }
    }
}

  best regards
anas-kal2

0
Comment
Question by:anas-kal2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
rameedev earned 500 total points
ID: 18018377
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question