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\B lue 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 10618
Sharon,
Take a look at the Bitmap.LockBits () method, may be what you need.
Regards - Octavio
"Sharon" <Sh****@discuss ions.microsoft. com> escribió en el mensaje
news:6E******** *************** ***********@mic rosoft.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\B lue 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 codepage system
wide. As much as it sounds good, UTF/Unicode encoding is not an option,
nor is changing the codepage.
Tackling the first is easy via Encoding.Default.GetBytes and shoving it
over the network. However, Encoding.Default is the...
|
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 called to_single_byte and to_multi_byte
which convert a given multi byte character to single byte and vice
versa respectively.
thanks in advance
mailar
|
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 seem to get the data
passed to the handler.
The following is the code that I have so far.
In the ViewPics.aspx file I have...
|
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 is proving to be more difficult. These
pictureboxes are bound to an AccessDB. If the user wants to add an image,
they select an image using an OpenFileDialog:
Dim result As DialogResult = Pic_Sel.ShowDialog()
If (result = DialogResult.OK) Then
| |
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
End Function
Private Function UStr2Bstr(UStr)
|
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 height;
|
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. Unfortunately I cannot find an
efficient way to do this in C#. I need to do this at 10fps+ with 1hour+
data files.
My current approach is read a byte from the filestream, then create a
MemoryStream to the created byte and then a bitmap from the memory
|
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, I want to do the same thing in pure(unmanaged) C++.
I searched the Internet but could not find any satisfactory solutions. I am really in need of help! Is there anyone to explain how I can implement these functions by not using .NET library?
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |