Click here to Skip to main content
16,017,922 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hi all
as a matter of fact I'm writing an image processing app by c#.net.
here I make an image based on the other image .
it means that "I have an image and I make some changes on it and save it again" but the problem is "the thumbnail of image doesn't change" . very simple code like this :

C#
string strPath="c:\\bb.jpg",strMainPicPath="c:\\aa.jpg" ;
Image imgBase;
imgBase = Image.FromFile(strMainPicPath);

SolidBrush brush = new SolidBrush(cWhite);
Font fntB = new Font("tahoma", 8, FontStyle.Bold);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(imgBase);
g.DrawString("Test String", fntB, brush, 100, 100);
g.Dispose();

imgBase.Save(strPath, System.Drawing.Imaging.ImageFormat.Jpeg);
imgBase.Dispose();


problem is just thumbnail of image .
Posted
Updated 4-Aug-12 4:32am
v2
Comments
[no name] 4-Aug-12 10:39am    
Since you are not creating a thumbnail of your image how do you expect it to change?
OriginalGriff 4-Aug-12 10:59am    
I assume he means the folder thumbs.db cache, but it's fine on mine...
Max110 4-Aug-12 14:19pm    
it is not about folder or such external things . it's about in-image .
Wes Adey , how I should make thumbnail for an image file .just watch this screen shot to know more about my problem .(http://darion.ir/max/ex.jpg) in this window I selected 3rd image and windows shows the preview of image above . just watch , there is nothing in Icon (thumbnail) but lots of things in image !?
OriginalGriff 4-Aug-12 10:58am    
At first I assumed that this meant that the thumbs.db cache was not being updated, but I tried it on my system, just changing the paths in your code to a temporary folder with some images in it, and it worked fine.
What are you doing that I'm not, or vice versa?

1 solution

This is pretty bad code. Always use the using construct to force things to be disposed. As others have said, if you change your image, you also need to generate a new thumbnail, that seems obvious.
 
Share this answer
 
Comments
Max110 5-Aug-12 2:02am    
and your answer pretty useless one :D
if I knew how to generate a new thumbnail I didn't ask here . I searched web for some hours and couldn't find good solution for that . if u have a good way to generate new thumbnail I'm a good student for your teach.
Christian Graus 5-Aug-12 2:03am    
Your question is useless :-) Where does your 'thumbnail' come from if you don't generate it ? If you mean the thumbnails windows generates, delete the thumbs.db file to force them to regenerate. If not, then you can pass your image in to a Bitmap constructor with a smaller size, to create a thumbnail.
Max110 16-Aug-12 6:08am    
maybe I can't explain my problem . I use a pure photo and put lots of graphics on it . them I save it . but the problem is saved image don't show new graphics in it's own thumbnail . when I save it by photoshop again photo become standard but I don't want to do that . and I don't want to have new photos as thumbnails.
the problem is just with one photo and it's own thumbnail !
Christian Graus 16-Aug-12 11:32am    
You have the answer. The system thumbnails is in the thumbs.db file, delete it to regenerate that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900