473,669 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple images via one MemoryStream?

Hi,
I'm trying to write a set of charts (as bitmap objects) out to a memory
stream so that a variable number of charts can be displayed using just one
html <img> tag in a holder page. I have everything working except that only
one chart is ever displayed, no matter how many are actually created. The
vb codebehind is called by being placed as the source for an img tag in a
holder page. The holder page also provides a filter for the rendering code
in the form of a dropdownlist - the selected value of which is passed as a
param to the SQL sproc.

Here's the particular section of my code that is outputting the image:

[BEChart is of type BitMap]
<-snipped->
Dim memStream As New System.IO.Memor yStream

Try
' 'Write the chart images held in the array to the output stream
For iLoop = 0 To aryEnts.GetUppe rBound(0)
If Not IsNothing(aryEn ts(iLoop).BECha rt) Then
'Add the current chart to the stream
aryEnts(iLoop). BEChart.Save(me mStream,
System.Drawing. Imaging.ImageFo rmat.Png)
End If
Next
''Get beginning of stream...
memStream.Seek( 0, IO.SeekOrigin.B egin)
''...and write it all out
memStream.Write To(Response.Out putStream)

Catch ex As Exception
strMsg = ex.Message.ToSt ring
Finally
memStream.Close ()
End Try

<-end->

Has anyone taken this approach before?

I wonder if the use of the single img tag on the holder page is forcing IE
only render one image (happens to be the last one generated in the loop).

I also wonder if the memStream is being overwritten instead of concatenated,
as the stream position value shown in the "locals" panel seems to jump
around and not always be at the end of the stream, which is where I would
have expected it to be...

E.g.
pass 1: capacity/length = 4706, position = 4706
pass 2: capacity/length = 4076, position = 2098
pass 3: capacity/length = 4076, position = 2062

Thanks for any help offered!
--
Alec MacLean

Nov 18 '05 #1
1 2894
Hi Alec,

Hard to say for sure what ALL of your problems are, but at least one of them
is that you are indeed overwriting the images in the memory stream. Another
is that you can't simply concatenate Bitmaps together. I can't tell from
your message whether you are using a separate ASPX page to generate the
image, but that is a necessity (an HTML document, which is what the img tag
is in, is a text file, and images must be requested separately by the
browser). And you should be sure that what you want to do is to combine
these images; the result may not be what you expect or desire. I identified
a couple of other potential issues you may be having, but I think you need
to re-evaluate your overall approach first. You're jumping through a lot of
hoops to avoid a little HTML (extra image tags) in your ASPX page.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Alec MacLean" <al**********@c opeohs.com.NO_S PAM> wrote in message
news:#r******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
I'm trying to write a set of charts (as bitmap objects) out to a memory
stream so that a variable number of charts can be displayed using just one
html <img> tag in a holder page. I have everything working except that only one chart is ever displayed, no matter how many are actually created. The
vb codebehind is called by being placed as the source for an img tag in a
holder page. The holder page also provides a filter for the rendering code in the form of a dropdownlist - the selected value of which is passed as a
param to the SQL sproc.

Here's the particular section of my code that is outputting the image:

[BEChart is of type BitMap]
<-snipped->
Dim memStream As New System.IO.Memor yStream

Try
' 'Write the chart images held in the array to the output stream
For iLoop = 0 To aryEnts.GetUppe rBound(0)
If Not IsNothing(aryEn ts(iLoop).BECha rt) Then
'Add the current chart to the stream
aryEnts(iLoop). BEChart.Save(me mStream,
System.Drawing. Imaging.ImageFo rmat.Png)
End If
Next
''Get beginning of stream...
memStream.Seek( 0, IO.SeekOrigin.B egin)
''...and write it all out
memStream.Write To(Response.Out putStream)

Catch ex As Exception
strMsg = ex.Message.ToSt ring
Finally
memStream.Close ()
End Try

<-end->

Has anyone taken this approach before?

I wonder if the use of the single img tag on the holder page is forcing IE
only render one image (happens to be the last one generated in the loop).

I also wonder if the memStream is being overwritten instead of concatenated, as the stream position value shown in the "locals" panel seems to jump
around and not always be at the end of the stream, which is where I would
have expected it to be...

E.g.
pass 1: capacity/length = 4706, position = 4706
pass 2: capacity/length = 4076, position = 2098
pass 3: capacity/length = 4076, position = 2062

Thanks for any help offered!
--
Alec MacLean

Nov 18 '05 #2

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

Similar topics

11
5288
by: Detlef Hüttenbach | last post by:
Whereas loading tiffs and pngs from file into an Image WebControl work, the images aren't shown when loaded from streams: In a WebForm, the image's property "ImageUrl" is set to a handler, and this handler gets the image from a database. Please check the various image formats. (The images are stored in a SQL database as Image type.) I post you a demo HTTP handler below. I guess, it's the ViewState which messes up (in Windows Forms I...
3
3076
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first and then parse the actual response and modify the src attribute of the
9
9772
by: charliewest | last post by:
Hello - I have images saved in my SQL SERVER 2000 database. Using ASP.NET (C#) is there any way to temporarily save an image to a session object, and after running some other operations, later retrieve the image from the session object, convert it back to an image, and re-save it to the database? Thanks?
8
3598
by: Bob | last post by:
I'm looking for an example of how to extract images from an Access 97 blob into an asp datagrid. Anybody have examples?
4
3946
by: Lindsey Howell | last post by:
Hello, I've encountered a problem when trying to display BLOB images from a SQL database using VB.NET. This is the code which generates the error: Dim mySqlConnection As SqlConnection = New SqlConnection(connectionString) Dim mySqlCommand As SqlCommand = New SqlCommand(queryString, mySqlConnection) Dim ms as MemoryStream = New MemoryStream
3
7458
by: Alan | last post by:
Hi, I'm converting a database application from Access 97 to C#/SQL Server. Old database contains some images in OLE fields. I've figured out that there's OLE header preceeding actual image data and dealt with some of the images which were in standard BMP format but most of the images are in some other format which is displayed ok in access application and can be copy/pasted to any image editor but when doubleclicking it doesn't open any...
5
15000
by: Sameer Gupta | last post by:
what are options for opening / handling tiff files in .Net framework ? which is the best library, namespace ? Please help Regards Sameer Gupta C# Designer & Developer Siemens UK
1
2437
by: san123456789 | last post by:
Hi, Im using a MS SQL server to store images... Im creating a windows form application using C#. I need to store and retrieve images from the database. This is my code to store images: pictureBox.Image = new System.Drawing.Bitmap(this.openFileDialog.FileName);
2
1842
by: Marco Pais | last post by:
Hi there. I'm developing a small application that uses Web Services to access database and store data. At some point, I store some images, by inserting the absolute image path into a varchar field (SQL Server 2005). Images themselves are copied to that path on the server. To read the images, I just use this path. However, some workstations have to authenticate the server that path. To
0
8462
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
8893
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
8802
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 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...
0
8658
tracyyun
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...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
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
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
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.