image scaling

M

Michael Hübner

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
 
M

Michael Nemtsev

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);
 
B

Braulio Diez

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
/// ------------------------------
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top