Thread: C# Image Processing :

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    2

    C# Image Processing :

    I import .jpg to database
    with BitMap Object to byte[]

    Bitmap bm = new Bitmap(imagePath);
    FileInfo fileInfo = new FileInfo(imagePath);
    MemoryStream ms = new MemoryStream();
    bm.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
    byte[] byteImage = ms.GetBuffer();

    then Export byte[] to .jpg

    Stream str = new MemoryStream((Byte[])dr[0]);
    Bitmap bm= new Bitmap(str);

    bm.Save(imagePath + "//" + this._lisrImageAll[id].imageName, System.Drawing.Imaging.ImageFormat.Jpeg);


    But!!!! size of image not equal ,


    Help me Please ,Thank you very much

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    If you mean that the size goes from say 9kb to 8kb then that's expected since you compress using jpeg when saving, which probably won't result in the exact same image.

    Why do you have to convert the image type? Can't you just save the jpg as it is, using System.IO.File.ReadAllBytes and System.IO.File.WriteAllBytes?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    2

    Smile

    Quote Originally Posted by Magos View Post
    If you mean that the size goes from say 9kb to 8kb then that's expected since you compress using jpeg when saving, which probably won't result in the exact same image.

    Why do you have to convert the image type? Can't you just save the jpg as it is, using System.IO.File.ReadAllBytes and System.IO.File.WriteAllBytes?




    Thanks for answer, I will try

    I'm programming Viewer and compare Image ,The DB for storing images.
    image to be used to compare the image stored in the DB. That the same?
    (weidth,heigth,size[byte]) Is true Not Import

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 12:10 PM
  3. Replies: 4
    Last Post: 03-02-2003, 09:12 AM
  4. Memory Allocation in Intell Image processing liberary
    By nisar in forum Windows Programming
    Replies: 0
    Last Post: 01-12-2003, 07:29 AM
  5. Image rotation using intel image processing
    By sunis in forum Windows Programming
    Replies: 1
    Last Post: 11-18-2002, 02:40 AM