Directorio

Publicidad Enviar Tutorial Foro Contactar Noticias PGN Políticas De Privacidad Subscríbete a las noticias de PGN
 
 
a Secciones b
Programación :
Flash
Java
Delphi
C++
Visual Basic
Rpg Maker
Game Maker
Asp
Diseño Gráfico :
3Ds Max
Photoshop
Blender
Entidad 3D
Cinema 4D
Desarrollo Web :
Dreamweaver
Promocionar Web
Gana Dinero Con Tu Web
Alojamiento Web
Otros :
Ubuntu y Linux
Códigos De Fuente
Informática General
c   d
 
 
 
 
 
 
Contenido

Redimensionar Imagen En C

 

Este tutorial le explica una función que podrá utilizar para redimensionar una imagen en C, esto le puede servir cuando una imagen no es válida para su proyecto y asín sacarle beneficios, también puede ver algunas funciones de este código que le pueden ayudar en otros proyectos.

public static byte[] ResizeImageFile(byte[] imageFile, int targetSize)
{
    Image original = Image.FromStream(new MemoryStream(imageFile));
    int targetH, targetW;
    if (original.Height >;; original.Width)
    {
        targetH = targetSize;
        targetW = (int)(original.Width * ((float)targetSize / (float)original.Height));
    }
    else
    {
        targetW = targetSize;
        targetH = (int)(original.Height * ((float)targetSize / (float)original.Width));
    }
    Image imgPhoto = Image.FromStream(new MemoryStream(imageFile));
    // Create a new blank canvas.  The resized image will be drawn on this canvas.
    Bitmap bmPhoto = new Bitmap(targetW, targetH, PixelFormat.Format24bppRgb);
    bmPhoto.SetResolution(72, 72);
    Graphics grPhoto = Graphics.FromImage(bmPhoto);
    grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
    grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
    grPhoto.PixelOffsetMode = PixelOffsetMode.HighQuality;
    grPhoto.DrawImage(imgPhoto, new Rectangle(0, 0, targetW, targetH), 0, 0, original.Width, original.Height, GraphicsUnit.Pixel);
    // Save out to memory and then to a file.  We dispose of all objects to make sure the files don't stay locked.
    MemoryStream mm = new MemoryStream();
    bmPhoto.Save(mm, System.Drawing.Imaging.ImageFormat.Jpeg);
    original.Dispose();
    imgPhoto.Dispose();
    bmPhoto.Dispose();
    grPhoto.Dispose();
    return mm.GetBuffer();
}

tutorial de: trucos

 
1 Enlaces 1
Anuncios Para Vender
Apuestas
Películas Gratis
Directorio Web SEO
Solicite sus prestamos en Openbank
Hechizos
Calendario 2009
Tutoriales gratis
Diseño web
Tarot Amigo
Juegos Gratis
Car hire Malaga 
Marbella villas
Traductores aleman
Curiosidades

3D

1   1

 

 
 
       
       
       
       
   

 
Programación y Diseño ©2008 www.programacion-ard.com Todos los derechos reservados Contactar