473,893 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert from Image to Bitmap

With two controls a PictureBox and another "PictureBox like" , Pic2, a
control from a dll, I'm stuck on cannot implicity convert
System.Drawing. Image to System.Drawing. Bitmap error.

How do I convert the following code so that the Pic2 can accept the Image
from the stream where it wants Picture property not and Image property.
Here is a snippet, I'm trying to avoid writing to disk.:

Image i = Pic1.Image;

MemoryStream ms = new MemoryStream();

i.Save(ms, ImageFormat.Jpe g); // need to save in jpeg for Pic2

//Read from MemoryStream into Byte array.

Byte[] bytBLOBData = new Byte[ms.Length];

ms.Position = 0;

ms.Read(bytBLOB Data, 0, Convert.ToInt32 (ms.Length));

Pic2.Picture = Image.FromStrea m(ms); // this is the line throwing the
"cannot convert System.Drawing. Image to System.Drawing. Bitmap
Thanks any help would be appreciated,
--
Fritz
Nov 15 '05 #1
1 50682
Hi Fritz,

Introduce an intermediate variable like thi:
ms.Read(bytBLOB Data, 0, Convert.ToInt32 (ms.Length));
Image img = Image.FromStrea m(ms);
Pic2.Picture = img;

And inspect the actual type of this "img" variable.
By the way, why is your assigment of one PictureBox's Image to another's is
so complicated?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Fritz Switzer" <fr***********@ comcast.net> wrote in message
news:e2******** *****@TK2MSFTNG P11.phx.gbl... With two controls a PictureBox and another "PictureBox like" , Pic2, a
control from a dll, I'm stuck on cannot implicity convert
System.Drawing. Image to System.Drawing. Bitmap error.

How do I convert the following code so that the Pic2 can accept the Image
from the stream where it wants Picture property not and Image property.
Here is a snippet, I'm trying to avoid writing to disk.:

Image i = Pic1.Image;

MemoryStream ms = new MemoryStream();

i.Save(ms, ImageFormat.Jpe g); // need to save in jpeg for Pic2

//Read from MemoryStream into Byte array.

Byte[] bytBLOBData = new Byte[ms.Length];

ms.Position = 0;

ms.Read(bytBLOB Data, 0, Convert.ToInt32 (ms.Length));

Pic2.Picture = Image.FromStrea m(ms); // this is the line throwing the "cannot convert System.Drawing. Image to System.Drawing. Bitmap
Thanks any help would be appreciated,
--
Fritz


Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4298
by: News VS.NET \( MS ILM \) | last post by:
Hello I have the following: Dim myBitmap As New Bitmap(600, 500) Q: How to convert a Bitmap to a Buffer() of Bytes
1
5427
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a web form to upload a TIFF image (scanned images) and convert it to a JPEG before I insert it into SQL Server. The file upload part works great, but I can;t convert the image. I certainly don't want to upload it the the server filesystem, convert...
5
9659
by: Socrates | last post by:
I am interested in developing an online utility that will enable users to copy and past any image (or upload any image on the internet) to the online utility, which will then convert the image to text. The user may "convert image to text" and copy and paste the text displayed into any word document, or send the text displayed to the recipient's email address or can download the text file as a zipped text file that will be presented to...
5
9106
by: stef | last post by:
hello I can find all kind of procedures to convert an array to a bitmap (wxPython, PIL), but I can't find the reverse, either - convert a bitmap to an array or - read a bitmap file to an array
1
1483
by: gnkt4ujt2002 | last post by:
how to convert image into hex format in vs.net 2003 ....bcoz i hav 2 send image on mobile using sms tgate way.. i hav a clickatell sms gate way...
2
2941
by: Peter Oliphant | last post by:
The Image class allows loading a bitmap from a graphic file. So far I've gotten it to work with JPG and BMP files. What other graphic file formats are supported in this way? Is this fixed based on the .NET Framework used (e.g., the Image class defines which formats can be used), or can different file formats be added after-the-fact (end-user capability in contrast to developer implementation)? Also, is it possible to save an image in...
1
2891
by: =?Utf-8?B?UmljYXJkbyBGdXJ0YWRv?= | last post by:
I'm using OpenGL in Visual Basic .net 2005 and i need to use the following function glBitmap(width as integer,height as integer, xorig as single, yorig as single, xmove as single, ymove as single, bitmap as System.InPtr) or glBitmap(width as integer,height as integer, xorig as single, yorig as single, xmove as single, ymove as single, bitmap() as byte)
4
1816
by: alarock | last post by:
hi, I have performed some drawing using Vector image,DrawRectangle etc... and then i converted to raster Image(bitmap) i found in the zoomed raster image(bitmap) the outer boundary of the raster image(bitmap) is blurry. i used Interpolation mode,smoothing mode,,and tried a lot ..... i cant able to solve this problem in C#...Please help me to solve this...... Regards, alarock(algates)
3
3971
by: surajhs | last post by:
hi, I am working on java applet, i created a interface to view image in panel on jlist selected image item which is in local machine path, Now i need to convert image to xml and along with i will open image viewer add some annotations save it in that xml file. Please help me with sample code or links. Thank you in advance
1
4024
by: surajhs | last post by:
i need to convert image to binary data and create xml file in applet, Please send samples links
0
9982
marktang
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...
0
9830
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,...
0
11243
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7173
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5858
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4684
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
2
4280
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3289
bsmnconsultancy
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...

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.