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

ArgumentException @ Image.FromStream(stream)

I get an "ArgumentException: Invalid parameter used at

System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement)"

exception. it is too ridicilious to get such an exception, can anyone see what

might cause that exception?

(By the way, i am trying to throw the header part of the image away and extract only
the image data)

the related source code is shown below:
private void button1_Click(object sender, System.EventArgs e)
{

string file_name = @"C:/...\IM1";
FileStream fs = new FileStream(file_name, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);

//BinaryReader br = new BinaryReader(File.OpenRead("C:/.../IM1"));
try
{
int numbytes = 140672 ;

int offset = 9600 ;

int totbytes=0;

byte[] bytearr = new byte[numbytes];

while( totbytes < (numbytes-offset) )
{
int i = br.Read(bytearr, offset,numbytes-offset) ;

totbytes+=i;
}

MemoryStream ms = new MemoryStream (bytearr,0,bytearr.Length) ;

Image img = Image.FromStream(ms,true);

//picbox.Image = new Bitmap(ms);

picbox.BackgroundImage = img ;
br.Close();
ms.Close();

}

catch( Exception exc )
{
textbox.Text = exc.ToString();
}

}

--------------------------------
From: halise irak

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Q6akrCogcUeY5gT7XPRQBA==</Id>
Jul 21 '05 #1
1 5126
How do you think the FromImage() method will recognize the bitmap type if
you throw away the header?
"halise irak via .NET 247" <an*******@dotnet247.com> schrieb im Newsbeitrag
news:#s**************@TK2MSFTNGP12.phx.gbl...
I get an "ArgumentException: Invalid parameter used at

System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement)"
exception. it is too ridicilious to get such an exception, can anyone see what
might cause that exception?

(By the way, i am trying to throw the header part of the image away and extract only

the image data)

the related source code is shown below:
private void button1_Click(object sender, System.EventArgs e)
{

string file_name = @"C:/...\IM1";
FileStream fs = new FileStream(file_name, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs);

//BinaryReader br = new BinaryReader(File.OpenRead("C:/.../IM1"));
try
{
int numbytes = 140672 ;

int offset = 9600 ;

int totbytes=0;

byte[] bytearr = new byte[numbytes];

while( totbytes < (numbytes-offset) )
{
int i = br.Read(bytearr, offset,numbytes-offset) ;

totbytes+=i;
}

MemoryStream ms = new MemoryStream (bytearr,0,bytearr.Length) ;

Image img = Image.FromStream(ms,true);

//picbox.Image = new Bitmap(ms);

picbox.BackgroundImage = img ;
br.Close();
ms.Close();

}

catch( Exception exc )
{
textbox.Text = exc.ToString();
}

}

--------------------------------
From: halise irak

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Q6akrCogcUeY5gT7XPRQBA==</Id>

Jul 21 '05 #2

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

Similar topics

3
by: CanyonJ | last post by:
I've been running into a frustrating problem for a while now. I use image.FromStream to open a tif, then perform some drawstring methods, and then save the file again. The tiffs are in 1 bit per...
1
by: DotNetJunkies User | last post by:
i am using a dll that places an image data in memory and returns to me two wariable long P1 and long P2 i am using C# P1 is the memory address and P2 is the number of bytes written i want to place...
6
by: Peder Y | last post by:
Surely, anyone can read it's attributes and methods... Now, how does Image store the image data? How does it discern between e.g. jpg, gif and bmp. Does it know it's own size, or does one need to...
4
by: Detlef Huettenbach | last post by:
I was trying to convert a Windows Forms prototype application to an ASP.NET solution that makes use of loading data streams into the Image Web/Windows control. For WinForms no problem. However in...
6
by: David W. Simmonds | last post by:
I know that I can create an Image object by using a path like C:\MyPictures\pic.jpg, but how can I create an Image object by using a path like /MyPictures/pic.jpg where the path is relative to the...
0
by: Oleg Ogurok | last post by:
Hi all, I'm having this problem. I have a 50x50 GIF image with a transparent background. I'm trying to resize it to 25x25 using GDI+ capabilities. With Windows Forms' Image control, the image...
9
by: Tom John | last post by:
Hi I am storing images in an access database, based on an MSDN article. The code i use to store is as follows: <code> 'Create the command object Dim command As New...
1
by: halise irak via .NET 247 | last post by:
I get an "ArgumentException: Invalid parameter used at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement)" exception. it is too ridicilious to get such an...
2
by: Patrick F | last post by:
Hi, i have a resourcefile with my project that contains a jepg image. Now i want to retrive that image to a Image m_Image in my program. Whats the best way to do this?
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.