image scaling

Discussion in 'ASP .Net' started by Michael Hübner, Nov 18, 2007.

  1. Hi guys,

    I need to scale an image before inserting it into a database. But I
    really have no idea - everything on the net that I have found so far is
    dealing with files that are physically stored in a folder. Does anyone
    of you have any sample code or links for me?

    Thanks in advance,

    Michi
     
    Michael Hübner, Nov 18, 2007
    #1
    1. Advertising

  2. You are in the right direction :)
    You can use the samples you found. Everything you need is consider working
    with your images from memory stream, not from the file stream like in folders.

    Smth like this
    byte[] b = (byte[])cmd.ExecuteScalar();

    // Open a stream for the image and write the bytes into it
    MemoryStream stream = new System.IO.MemoryStream(b, true);
    stream.Write(b, 0, b.Length);

    // Create a bitmap from the stream
    Bitmap bmp = new Bitmap(stream);

    --
    WBR, Michael Nemtsev [.NET/C# MVP].
    Blog: http://spaces.live.com/laflour



    "Michael Hübner" wrote:

    > Hi guys,
    >
    > I need to scale an image before inserting it into a database. But I
    > really have no idea - everything on the net that I have found so far is
    > dealing with files that are physically stored in a folder. Does anyone
    > of you have any sample code or links for me?
    >
    > Thanks in advance,
    >
    > Michi
    >
     
    Michael Nemtsev, Nov 18, 2007
    #2
    1. Advertising

  3. Michael Hübner

    Braulio Diez Guest

    You have to play with streams, about how to scale (easy algorithm) and
    playing with the image in memory:


    http://www.thescripts.com/forum/thread225328.html

    http://www.codeproject.com/csharp/imageresize.asp

    http://www.dotnet247.com/247reference/msgs/31/156505.aspx

    http://www.informit.com/articles/article.aspx?p=377078&rl=1

    About how to save images on SQL Server:

    http://www.codeproject.com/useritems/Store_images_in_SQL_Serve.asp

    HTH
    Braulio

    /// ------------------------------
    /// Braulio Diez
    ///
    /// http://www.tipsdotnet.com
    /// ------------------------------




    "Michael Hübner" wrote:

    > Hi guys,
    >
    > I need to scale an image before inserting it into a database. But I
    > really have no idea - everything on the net that I have found so far is
    > dealing with files that are physically stored in a folder. Does anyone
    > of you have any sample code or links for me?
    >
    > Thanks in advance,
    >
    > Michi
    >
     
    Braulio Diez, Nov 19, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scaling PNG image

    , Apr 29, 2004, in forum: Java
    Replies:
    3
    Views:
    708
    Thomas Weidenfeller
    Apr 30, 2004
  2. Daniel L. Bateman

    Overriding browser image auto-scaling

    Daniel L. Bateman, Oct 29, 2003, in forum: HTML
    Replies:
    6
    Views:
    1,277
    Mark Parnell
    Oct 30, 2003
  3. Yofnik
    Replies:
    3
    Views:
    489
    Yofnik
    Jan 27, 2007
  4. pmennen

    Specifying 100% image scaling

    pmennen, Jan 14, 2007, in forum: HTML
    Replies:
    11
    Views:
    614
    Roy A.
    Jan 16, 2007
  5. Replies:
    1
    Views:
    507
    mlimber
    Jan 2, 2007
Loading...

Share This Page