Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

processing image with c# form

Posted on 2006-11-26
1
Medium Priority
?
1,815 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 1500 total points
ID: 18018377
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

664 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