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

About bitmap

Hi, Could anyone help me with this error.

I received this error "Invalid Parameter" with this code
fragment.

private void GetPicEmp(long IDNo)
{
byte[] b = TCSys.GetPicEmp(IDNo);
if(b.Length > 0)
{
MemoryStream stream = new MemoryStream(b,true);
stream.Write(b, 0, b.Length);
// Create a bitmap from the stream
Bitmap bmp = new Bitmap(stream); <-- THIS IS Where the
ERROR
// Check for scaling and assign the bitmap to the
Picturebox
if( bmp.Width > 224 && bmp.Height > 192)
{
Bitmap bmp1 = new Bitmap(bmp, new Size(224,192));
PicBox.Image = bmp1;
}
else
PicBox.Image = bmp;
// Close the stream
stream.Close(); }
}

Could any one give a suggestion to this problem?
Nov 15 '05 #1
1 2287
OTTOMH I think you need to seek the stream back to the beginning.

--
Bob Powell [MVP]
C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Tanchi" <ch***@mandaue.tti.com.ph> wrote in message
news:06****************************@phx.gbl...
Hi, Could anyone help me with this error.

I received this error "Invalid Parameter" with this code
fragment.

private void GetPicEmp(long IDNo)
{
byte[] b = TCSys.GetPicEmp(IDNo);
if(b.Length > 0)
{
MemoryStream stream = new MemoryStream(b,true);
stream.Write(b, 0, b.Length);
// Create a bitmap from the stream
Bitmap bmp = new Bitmap(stream); <-- THIS IS Where the
ERROR
// Check for scaling and assign the bitmap to the
Picturebox
if( bmp.Width > 224 && bmp.Height > 192)
{
Bitmap bmp1 = new Bitmap(bmp, new Size(224,192));
PicBox.Image = bmp1;
}
else
PicBox.Image = bmp;
// Close the stream
stream.Close(); }
}

Could any one give a suggestion to this problem?

Nov 15 '05 #2

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

Similar topics

7
by: BC | last post by:
Hi all, I have a method that accepts a string as the parameter. This can be a base64 image string, or just a normal string. Currently to test whether it's a image string or just a normal string,...
2
by: Tamer Abdalla via DotNetMonster.com | last post by:
Hello, everyone! I DO need some help in order to understand how to create graphics in VB.NET. I'm a little bit confused... I once knew a time when using Point & PSet was almost the only way to...
6
by: **Developer** | last post by:
usually I'd do: Drawing.Image.FromFile( I noticed I once did without thinking: Drawing.Bitmap.FromFile( I assumed this worked because Bitmap inherits from Image, but for fun I thought I'd...
7
by: Fir5tSight | last post by:
Hi All, I used the following code in C#: using System.Drawing; //blah blah blah Bitmap bmp = new Bitmap();
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
9
by: poifull | last post by:
Hi All, I have the following task: 1. create an image object in memory (a rectangle with nothing on it) 2. write some text on the rectangle 3. rotate the image 90 degree 4. save the image to a...
6
by: \Frank\ | last post by:
I trying to learn what a Bitmap is. Not a Managed Bitmap Object but one that, for example, comes from the clipboard with CF_BITMAP. I'm guessing that a CompatableBitmap is an array of indices...
2
by: Peter Oliphant | last post by:
I want to create a new Bitmap which is a portion of an existing Bitmap. For example, if I have a Bitmap that is 100x100 in size I might want to create a new Bitmap that is equivalent to the one...
5
by: =?Utf-8?B?QVRU?= | last post by:
I have a bitmap of 100X100. On the load, the bitmap is created by a function (createimage()). On my OnPaint, I draw the image back to the screen (e.Graphics.DrawImage( bitmap, destrect)). Now,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
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?
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...
0
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,...
0
jinu1996
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...

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.