Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

processing image with c# form

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

782 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