473,322 Members | 1,314 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,322 software developers and data experts.

How to save more than one image in one byte array using c#

Hello friend,

my problem is to save more than one fingerprint images in one byte array and then store in database(oracle).

i dont know how to solve it. But previously i had did image saving using byte array, but i want to know how to save more than one images in one database field....

actually i convert one image to byte array using the below code

pb1 = picturebox1
pb2 = picturebox2

//Ist image

MemoryStream ms = new MemoryStream();
pb1.Image.Save(ms,pb1.Image.RawFormat);
len = ms.Length;
b = new byte[Convert.ToInt32(len)];


//IInd image

pb2.Image.Save(ms, pb2.Image.RawFormat);
len = ms.Length;
c = new byte[Convert.ToInt32(len)];


how to store these two different byte array (b & c) in one byte array

thanks in advance...

anand
Oct 11 '08 #1
8 9992
tlhintoq
3,525 Expert 2GB
Is this a school homework assignment?
Oct 12 '08 #2
Y r u asking like this... if u know just rpl, else keep close all of u.....
Oct 13 '08 #3
Plater
7,872 Expert 4TB
Well the code you have, seems like BOTH images should be contained in that memorystream object, so they're both already together.
I would recomend putting some type of deliminator between the two so you can tell them apart when you need to.

As for why you were asked if it was homework problem, please see the Posting Guidelines about how we will not do your homework for you.
Oct 13 '08 #4
Curtis Rutland
3,256 Expert 2GB
Y r u asking like this... if u know just rpl, else keep close all of u.....
Please read the Things that are generally unacceptable and How to ask a question entry as well.

Use Clear English to write your question in if possible, try to avoid using abbreviations
Do not use leet speak or text speak, they are not Clear English
Posting in a language other than English. This is a multinational forum and as such uses English as its language as it is the international language of business. If your English is not so good then please say so and the experts will try to make some allowance for this.
Please don't use "txt" speak like "pls" and "Y r u." Also, it's rude to our long standing members for you to tell them to give you the answer or go away.

MODERATOR
Oct 13 '08 #5
Well the code you have, seems like BOTH images should be contained in that memorystream object, so they're both already together.
I would recomend putting some type of deliminator between the two so you can tell them apart when you need to.

As for why you were asked if it was homework problem, please see the Posting Guidelines about how we will not do your homework for you.
Plater, thanks for your reply... and this is not a school home work problem, but i am new to c#.net. i am facing the above problem for past several days and i cant get any proper solution... Could u post...? I need how to save more than one image in a single field(blob) in database
Oct 15 '08 #6
Plater
7,872 Expert 4TB
The MemoryStream can do it, you just have to be a bit more sneaky then you would think.

Expand|Select|Wrap|Line Numbers
  1. //Here is the main stream
  2. MemoryStream fullstream = new MemoryStream();
  3.  
  4. //dummy stream
  5. MemoryStream ms = new MemoryStream();
  6. Bitmap bm = (Bitmap)Bitmap.FromFile(@"C:\temp.bmp");
  7. bm.Save(ms, ImageFormat.Bmp);    
  8.  
  9. //write one instance of the image
  10. ms.WriteTo(fullstream);
  11. //write another instance of the image
  12. ms.WriteTo(fullstream);
  13. //Now fullstream has 2 images in it (you can verify by the .Length property of the stream)
  14.  
  15. //get the byte[] of two images
  16. byte[] superbuffer=fullstream.ToArray();
  17.  
Oct 15 '08 #7
The MemoryStream can do it, you just have to be a bit more sneaky then you would think.

Expand|Select|Wrap|Line Numbers
  1. //Here is the main stream
  2. MemoryStream fullstream = new MemoryStream();
  3.  
  4. //dummy stream
  5. MemoryStream ms = new MemoryStream();
  6. Bitmap bm = (Bitmap)Bitmap.FromFile(@"C:\temp.bmp");
  7. bm.Save(ms, ImageFormat.Bmp);    
  8.  
  9. //write one instance of the image
  10. ms.WriteTo(fullstream);
  11. //write another instance of the image
  12. ms.WriteTo(fullstream);
  13. //Now fullstream has 2 images in it (you can verify by the .Length property of the stream)
  14.  
  15. //get the byte[] of two images
  16. byte[] superbuffer=fullstream.ToArray();
  17.  

Thanks for your reply Plater,
I checked the codes, but i am getting only one image, even writing into the memory stream(full stream) two times...

could you please explain some more clear...

thanks
anand
Oct 18 '08 #8
Plater
7,872 Expert 4TB
Well in my example, I used the same image for each instance.
It was just an example.
You will need to provide your own method for knowing where one image ends and another image begins.
Oct 20 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Mark Johnson | last post by:
How can you save all or a portion of the Grafics object to a Image/Bitmap ? I am try to save the Images from Cards.dll to a BitMap file. I can read in the Images to the Grafics, but when I try this...
9
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions...
1
by: Markusek Peter | last post by:
Hi, I'm using MySQLDriverCS. I've got no problem to store BLOB into database, but I can't get it back(save to file). Problem is with DataTable(returns string:( ) My code: -- DataTable dt = new...
15
by: Sharon | last post by:
Hello gurus, I have a System.IntPtr pointing to the memory address of my image (not a ..NET image). I wish to save this image data pointed by the IntPtr to a raw data file. The way I now to...
3
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
I'm having the wierdest problem. I'm trying to save images into a SQL 2005 database. the field is just called "IMAGES" and hte data type is "image". here is my code to save //following code...
4
by: Logician | last post by:
I am running on my PC Windows Forms to collect data from websites, including images. I hit a problem with images and javascript, and I would appreciate any help. The current code fails with a...
1
by: dodgeyb | last post by:
Hi there, Trying to allow client to upload image, thumbnail it, and save it into sql table image field. Code compiles & runs but image cannot be retrieved. any clues what I'm doing wrong pls ! ...
6
by: Jerry Spence1 | last post by:
I am using a network camera that saves the image in a byte array in memory (via their ocx component, and in the OnNewImage event I can get the pointer to the image and the byte length as...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.