I have 2 questions that are just the opposite to one another:
(1) I need to read an image file (like bitmap, jpeg etc.) and to save only
its data, I need to save his data in a raw data format, meaning; I don't want
to save the image header, only the pixels data.
the raw data should be saved in a byte array.
The direct way is to do a loop over the image pixels and to copy pixel by
pixel to the byte array.
I'm looking for another way to do that. Is there a .NET function/method that
does it?
The following code is not good because it saves also the bitmap header to
the byte array:
Bitmap img = Bitmap.FromFile(@"C:\WINDOWS\Blue Lace 16.bmp", true) as Bitmap;
MemoryStream ms = new MemoryStream();
img.Save(ms, img.RawFormat);
byte[] rawData = ms.ToArray();
(1) I have a raw data image in a byte array, and I need to build a bitmap
from it.
The raw data does not contain the image format (width and height), but I do
have it in other variables (int width; int height).
How do I do that?
--
Thanks
Sharon 1 10478
Sharon,
Take a look at the Bitmap.LockBits() method, may be what you need.
Regards - Octavio
"Sharon" <Sh****@discussions.microsoft.com> escribió en el mensaje
news:6E**********************************@microsof t.com... I have 2 questions that are just the opposite to one another:
(1) I need to read an image file (like bitmap, jpeg etc.) and to save only its data, I need to save his data in a raw data format, meaning; I don't want to save the image header, only the pixels data. the raw data should be saved in a byte array. The direct way is to do a loop over the image pixels and to copy pixel by pixel to the byte array. I'm looking for another way to do that. Is there a .NET function/method that does it?
The following code is not good because it saves also the bitmap header to the byte array: Bitmap img = Bitmap.FromFile(@"C:\WINDOWS\Blue Lace 16.bmp", true) as Bitmap; MemoryStream ms = new MemoryStream(); img.Save(ms, img.RawFormat); byte[] rawData = ms.ToArray();
(1) I have a raw data image in a byte array, and I need to build a bitmap from it. The raw data does not contain the image format (width and height), but I do have it in other variables (int width; int height).
How do I do that?
-- Thanks Sharon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christopher H. Laco |
last post by:
Long story longer. I need to get web user input into a backend system
that a) only grocks single byte encoding, b) expectes the data transer
to be 1 bytes = 1 character, and c) uses the HP Roman-6...
|
by: mailar |
last post by:
HI,
Can anyone tell me how is a multi_byte to single byte and vice versa
conversion done in DB2.
It would be great even if someone can tell me how Oracle does it?
Oracle already has functions...
|
by: Ben Terry |
last post by:
Can anyone tell me how to get data from a byte array into the following
structure?
public struct MESSAGE_LOG_HEADER_STRUCT2
{
public DateTime dtTimeStamp;
public Int32 dSerialNumber;
|
by: marvin |
last post by:
Hi,
I am trying to display images in a repeater from a SQL database and do
some transformations on the image prior to displaying them (such as
thumbnail with a shadow). The problem is I can't...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: Eugene Anthony |
last post by:
Private Function BStr2UStr(BStr)
'Byte string to Unicode string conversion
Dim lngLoop
BStr2UStr = ""
For lngLoop = 1 to LenB(BStr)
BStr2UStr = BStr2UStr & Chr(AscB(MidB(BStr,lngLoop,1)))
Next...
|
by: Zeke Zinzul |
last post by:
Hi Guys & Geeks,
What's the most elegant way of dealing with binary data and structures?
Say I have this (which I actually do, a woo-hoo):
struct Struct_IconHeader
{
byte width;
byte...
|
by: gsmith |
last post by:
Hello,
I am developing a video recording (mjpeg) system which records large
binary files. I need to read the JPEG data from the binary file and
create a bitmap object to be displayed....
|
by: yabansu |
last post by:
Hi all,
I think most of you probably know the two .NET framework functions, namely Encoding.GetBytes(string) and Encoding.GetString(byte), to convert string into byte array and vice versa.
Now,...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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...
|
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: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |