473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Thumbnail Generation

mo
Hi,
I have the following code to create a thumbnail from the input stream

System.Drawing.Image source;
source=System.Drawing.Image.FromStream(new
System.IO.MemoryStream(myData));
System.Drawing.Image image = source.GetThumbnailImage
150,150,null,IntPtr.Zero);
MemoryStream ms = new MemoryStream();
ImageFormat thisformat=image.RawFormat;
Bitmap imagebitmap = new Bitmap(image,150,150);
imagebitmap.Save(ms,thisformat);
ms.Seek(0,SeekOrigin.Begin);
byte[] SmallmyData = new byte[ms.Length];
FileStream newFile = new FileStream(strPath, FileMode.Create);
newFile.Write(Buffer, 0, SmallmyData.Length);
newFile.Close();

Two problems I have
1) imagebitmap.Save(ms,thisformat); line faults and cannot find the
value for thisformat (It works if I replace it with ImageFormat.Jpeg)
2) the file that gets created is corrupt.

ANy help is greatly appreciated.

Thanks,
Mo
Nov 18 '05 #1
1 1281

Try this code:

http://west-wind.com/weblog/posts/283.aspx

and

http://west-wind.com/weblog/posts/626.aspx
In addition to working <g>, the above code doesn't use GetThumbnailImage
which generally does a pretty poor job of creating thumbnails. The second
post talks about adding a switch for the InterpolationMode to further
enhance image quality of a resized image.

Regards,

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web
"mo" <le******@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
Hi,
I have the following code to create a thumbnail from the input stream

System.Drawing.Image source;
source=System.Drawing.Image.FromStream(new
System.IO.MemoryStream(myData));
System.Drawing.Image image = source.GetThumbnailImage
150,150,null,IntPtr.Zero);
MemoryStream ms = new MemoryStream();
ImageFormat thisformat=image.RawFormat;
Bitmap imagebitmap = new Bitmap(image,150,150);
imagebitmap.Save(ms,thisformat);
ms.Seek(0,SeekOrigin.Begin);
byte[] SmallmyData = new byte[ms.Length];
FileStream newFile = new FileStream(strPath, FileMode.Create);
newFile.Write(Buffer, 0, SmallmyData.Length);
newFile.Close();

Two problems I have
1) imagebitmap.Save(ms,thisformat); line faults and cannot find the
value for thisformat (It works if I replace it with ImageFormat.Jpeg)
2) the file that gets created is corrupt.

ANy help is greatly appreciated.

Thanks,
Mo

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Simon Wigzell | last post by:
I need a simple function to generate and save a thumbnail from a picture. It would require : Source Picture Fileame Thumbnail Height and Width Thumbnail Filename There are many pay programs...
0
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web...
0
by: Cecil Windham | last post by:
I'm enabling users to rotate photos and generate thumbnails. I have discovered that if, after a user rotates a photo 180 degrees, then generates a thumbnail, that the resulting thumbnail appears...
1
by: db | last post by:
In explorer you can change the view setting to thumbnails, and you get thumbnails even from movies. I want to do the same from asp.net. I want to create 'on the fly' thumbnails from some mpg...
1
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
4
by: dean.greg | last post by:
Im looking for a way to generate thumbnails from an image as fast as possible. Currently I'm using GDI+ however going from 1024x768 to 100x100 takes too long. I'd imagine the whole process can be...
7
by: oscartheduck | last post by:
Hi folks, I'm trying to alter a program I posted about a few days ago. It creates thumbnail images from master images. Nice and simple. To make sure I can match all variations in spelling of...
2
AaronL
by: AaronL | last post by:
Hello, I would like to have thumbnails generated automatically from images uploaded from my image upload system. Can anyone tell me what I need to do? Here is the link to my php info page, I'm...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.