Chinese (People's Republic of China)  English  Français


Supinfo-Projects.com
Tous les projets des élèves ingénieurs de Supinfo



Projets
  Dernier Projet
  Les plus populaires
  Tous les Projets

211 Visiteurs
3168 Projets


My Supinfo-Projects

   Connectez-vous
   Créez un Compte


Synopsis

   353 Visites
   Note INTERNET : 16
    (5 Votants)
   0 Commentaires

   Lire l'article

Evaluez cet article

20
18
16
14
12
10
8
6
4
2
0


Commentez cet article

Auteur :

Email :

Votre commentaire :



 
2004 - Pérennisation
ASP.Net GDI+
[40 mn de lecture - paru le 5/8/2004 1:54:12 PM - Public : Confirmé]

Auteur

degrem_mMichel DEGREMONT
Elève-Ingénieur Supinfo Paris
Promotion SUPINFO 2006

   Lui écrire
   Tous les projets de cet auteur
   Le mini-CV de cet auteur

3. Loading, Recording, Visualization

3.1. Creation of the Class traitementImage

In your Visual Project you must add a new Class which you entitle "traitementImage"

Place the following nameSpaces in the heading :

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using imagetest = System.Drawing; // create alias to avoid all ambiguity

And to add you these data members of the class into private so that they are not accessible:

private Image monImage; // // the image in progress
private String imageNom = ""; //name of image
private ImageFormat imageFormat; // format of image

3.2. Loading of the image

For the loading of the image one should not forgets to call the Dispose method of the images to guarantee a release of the resources, if the class would contain already an image.

/// <summary>
/// dispose ressource
/// </summary>

public void Dispose()
{
    if(monImage != null)
    monImage.Dispose();
}

To load the image one creates an Image object of the source file by using the methods FromFile or FromHbitmap or FromStream.

/// <summary>
/// load image
/// </summary>
/// <param name="cheminImage">
/// path if image
/// </param>

public void chargementImage(string cheminImage)
{
    if(monImage != null) monImage.Dispose();

    monImage = Image.FromFile(cheminImage);
    imageNom = cheminImage;
    imageFormat = monImage.RawFormat;
}

3.3. Save Image

The class Imaging itself carries out large work of recording of the image.

Although the garbage-collector can itself release the resources, it is not guaranteed that it does it and that can result in appreciably reducing the resources available for the system itself. The file name which is stored can be used as reference at the time of the next operations of recording.

The Save method sub-contracts with the method of the images by using the file name of origin previously stored.
The SaveAs method is declined in two overloads.


/// <summary>
/// save image
/// </summary>
public void SaveImage()
{
    monImage.Save(imageNom,imageFormat);
}

/// <summary>
/// save as
/// </summary>
/// <param name="nouveauNom">
/// name from image
/// </param>

public void SaveImageAs(String nouveauNom)
{
    monImage.Save(nouveauNom,imageFormat);
}

/// <summary>
/// save as image with a new name
/// </summary>
/// <param name="nouveauNom">
/// new name of image
/// </param>
/// <param name="format">
/// choice new Format (gif, jpg, bmp, tiff, etc.)
/// </param>

public void SaveImageAs(String nouveauNom,ImageFormat nouveauFormat)
{
    monImage.Save(nouveauNom,nouveauFormat);
}

3.4. Property of the image

We will establish several methods allowing us to have the maximum of information on the photograph which we want to treat: the taille(largor, height), resolution, format...

/// <summary>
/// return size of image
/// </summary>

public int Width
{
    get
    {
        return monImage.Width;
     }
}

/// <summary>
/// retourn height if image
/// </summary>

public int Height
{
    get
    {
        return monImage.Height;
    }
}

/// <summary>
/// return size of image
/// </summary>

public Size Size
{
    get
    {
        return monImage.Size;
    }
}
/// <summary>
/// return Horizontal resolution
/// </summary>

public float HorizontalResolution
{
    get
    {
        return monImage.HorizontalResolution;
    }
}
/// <summary>
/// return Vertical vertical
/// </summary>

public float VerticalResolution
{
    get
    {
        return monImage.VerticalResolution;
    }
}
/// <summary>
/// retunr format from image
/// </summary>

public string RawFormat
{
    get
     {
        return monImage.RawFormat.ToString();
    }
}

/// <summary>
/// retunr image type
/// </summary>

public string PixelFormat
{
    get
    {
        return monImage.PixelFormat.ToString();
    }
}


3.5. Weight of the image

For the poid I small appartée for you given an easy way makes in order to know the poid of a photograph (it is the same thing for any file)

Do not forget to import using System.IO; It is the namespace which gére files.

/// <summary>
/// return heigth
/// </summary>
/// <param name="cheminImage">
/// path of image
/// </param>

public string poidImage(string cheminImage)
{
    FileInfo monImagePoid = new FileInfo(cheminImage);// property nameSpace IO
    
    if(monImagePoid.Length > 1000000)
    {
        return (monImagePoid.Length /1000000) + " Mo";// return lenght in Mo
    }
    else
    {
        if(monImagePoid.Length > 1000)
        {
            return (monImagePoid.Length /1000) + " Ko";// return lenght in ko
        }
        else
        {
            return monImagePoid.Length + " octets";// return lenght in octect
        }
    }

}

 

3.6. Intanciation of the Class traitementImage

We will establish several methods allowing us to have the maximum of information on the photograph which we want to treat: the taille(largor, height), resolution, format...

in the aspx page place two control: a Label and ImageButton which you will nomerez respectively infoLabel and ImageButton1:

< asp:Label id="infoLabel "runat=server/>
< asp:ImageButton id="ImageButton1 "runat=server ImageUrl="fille:///E:\photo.JPG"/>

in the Behind code:

private void Page_Load(object sender, System.EventArgs e)
{
    String path = ImageButton1.ImageUrl.Replace("file:///","").ToString();

    traitementImage monImage = new traitementImage();// classe traitementImage

    monImage.chargementImage(path);// load image

   
    infoLabel.Text="<u>Propriété de l'image </u><br>";
    infoLabel.Text=infoLabel.Text + "<br>HorizontalResolution : " + monImage.HorizontalResolution;
    infoLabel.Text=infoLabel.Text + "<br>VerticalResolution : " + monImage.VerticalResolution;
    infoLabel.Text=infoLabel.Text + "<br>RawFormat : " + monImage.RawFormat;
    infoLabel.Text=infoLabel.Text + "<br>PixelFormat : " + monImage.PixelFormat;
    infoLabel.Text=infoLabel.Text + "<br>tailleImage : " + monImage.tailleImage;

    infoLabel.Text=infoLabel.Text + "<br>Poid mon image :" + monImage.poidImage(path);

}

What gives:



Articles de la même catégorie

 Pages : Top


173 Visites
0 Commentaires
Convert your XML pages in HTML
[10 mn de lecture - paru le 5/8/2004 1:12:11 PM - Public : Confirmé]

En savoir plus


323 Visites
0 Commentaires
Convertir un fichier XML en fichier HTML
[10 mn de lecture - paru le 5/8/2004 12:40:53 PM - Public : Confirmé]

En savoir plus


207 Visites
0 Commentaires
An introduction to XML
[20 mn de lecture - paru le 5/8/2004 11:23:36 AM - Public : Débutant]

En savoir plus

   Tous les Articles


SUPINFO Training Center peut vous proposer une formation ...

   Devenez Ingénieur Système Microsoft en 35 jours avec SUPINFO Training Center
   Devenez Certifiés Cisco en 13 jours avec SUPINFO Training Center
   Devenez Administrateur Système Microsoft avec SUPINFO Training Center
   Devenez Développeur Microsoft .NET en 13 jours avec SUPINFO Training Center



Powered by Campus-Booster Technology
Conditions d'utilisation & Copyright | Respect de la vie privée
© Copyright 1965-2006 Supinfo Paris, Paris Academy of Computer Science
Supinfo, Ecole Supérieure d'Informatique et Paris Academy Of Computer Science are trade marks.
23, rue de Château LANDON - 75010 PARIS - Phone : +33 (0) 153359 700 Fax : +33 (0) 153359 701

Web site autided by :