Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
good afternoon..

My program will take an image from user "picComputerImage" and matched it with different images that stored in my database..and display the matched in "picdatabaseImage" which is an imagebox.

I have a table called "Images" that contains "image_id" and "image" ..
in "image" field I store the name of image with extension
example: f.jpg
also, I keep all the images in a folder "pic"

I want to retrieve each image from that table and convert it to bitmap.Then I should re-size the bitmap

I tried this code but it didn't work..I'm getting stuck in my project...
C#
 foreach (DataRow dr in ds.Tables["Images"].Rows)
               {
path = "C:\\Users\\OMAN\\Desktop\\My Subjects\\INSTRUCTION _REPORTcourse\\compare\\compare\\pic\\" + dr["image"].ToString();

                 bmDatabaseImage = (Bitmap)Image.FromFile(path.ToString());
                   picDatabaseImage.Image = bmDatabaseImage;

                   // resize image
                   bmComputerImage = (Bitmap)picComputerImage.Image;
                   bmDatabaseImage = (Bitmap)picDatabaseImage.Image;

                   Bitmap bmNewCI = new Bitmap(bmComputerImage,600, 600);
                   Bitmap bmNewDI = new Bitmap(bmDatabaseImage, 600, 600);
                   picComputerImage.Image = bmNewCI;
                   picDatabaseImage.Image = bmNewDI;
Posted
Updated 6-Apr-13 0:37am
v2
Comments
OriginalGriff 6-Apr-13 6:59am    
When you say "it didn't work", what do you mean?
The code (despite doing a lot of silly things) will re-size your two images to 600x600.
What is it doing that it shouldn't, or not doing that it should?
hajis 6-Apr-13 10:48am    
I didn't get the correct result ..
I think the problem is in the loop that I use to get the image from Image's Column .
Is that way which I use is correct ??
hajis 6-Apr-13 13:11pm    
I change this line but there is an error I don't know how to fix it ..
;(

The error is " File Not Found Extension Unhandled"... Any idea??


bmDatabaseImage = (Bitmap)Image.FromFile("~\\pic\\" + dr["image"].ToString());

1 solution

I change this line but there is an error I don't know how to fix it ..
;(

The error is " File Not Found Extension Unhandled"... Any idea??


bmDatabaseImage = (Bitmap)Image.FromFile("~\\pic\\" + dr["image"].ToString());
 
Share this answer
 

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