Solved

processing image with c# form

Posted on 2006-11-26
1
1,804 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
1 Comment
 
LVL 5

Accepted Solution

by:
rameedev earned 500 total points
ID: 18018377
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now