Click here to Skip to main content
12,353,393 members (72,512 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# database image table
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...
 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 6-Apr-13 0:31am
hajis329
Edited 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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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());
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 6 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100