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

Add a Bitmap ???

I need to add a dynamical!! generated bitmap to an image
button! What is the way to do it? The ImageButton offers
only the URL property. But this are physical file paths.

Dim new_bitmap As Bitmap = New Bitmap(850, 200)

Dim image_button As New System.Web.UI.WebControls.ImageButton

Thanks a lot

Rob
Nov 17 '05 #1
3 2374
The problem you have is that your working in the server side's memory... and
so the image you're creating and using is, the server's buffer. When the
request from the client to the server is made to pass it a picture, it needs
to be a file that's requested, or the server won't know how to send it, and
the client won't know how to receive it and show it.

The only way you can do this is to first stream out the buffer, (i.e, save
the bitmap to disk), then take that URL you've just saved the file too and
pass that to the image button's URL.
I'd suggest using something like in the ASP page...

<A HREF="somefolder/somefile"><IMG BORDER=no ID=myImage
SRC="images/myTempPick.jpg"></A>

then when you've gotten the bitmap and saved it, something like... (aspx.vb
file)

dim ClientScript as String = ""
ClientScript += "<SCRIPT language=javascript>" & vbNewLine
ClientScript += " document.all.myImage.src = " & stringImageURL &
vbNewLine ' where stringImageURL is a string containing your image
location you've saved out
ClientScript += "</SCRIPT>
RegisterStartupScript( "ImageChange", ClientScript )

This code then writes the client side script to change your image URL from
the TempPick to whatever pic you now want. Note that I used HTML's standard
<IMG> rather than the <ASP:...>, I haven't played much with the ASP.net
controls in this way so am not sure what they'll do, try it!

hope that helps, and works!

Dan.
"Robert" <ro*******@gmx.com> wrote in message
news:09****************************@phx.gbl...
I need to add a dynamical!! generated bitmap to an image
button! What is the way to do it? The ImageButton offers
only the URL property. But this are physical file paths.

Dim new_bitmap As Bitmap = New Bitmap(850, 200)

Dim image_button As New System.Web.UI.WebControls.ImageButton

Thanks a lot

Rob

Nov 17 '05 #2
You don't want a Bitmap. You want an image format that IS supported by
browsers, such as JPG or GIF. What you need to do is to create an ASPX page
that uses Response.BinaryWrite() to write the binary image to the Response.
This ASPX page must also set the ContentType to "image/jpg" or "image/gif"
to inform the browser that it is not an ASPX page that is being returned,
but an image. Your image button can then use the URL of the ASPX page as the
URL to the image.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"Robert" <ro*******@gmx.com> wrote in message
news:09****************************@phx.gbl...
I need to add a dynamical!! generated bitmap to an image
button! What is the way to do it? The ImageButton offers
only the URL property. But this are physical file paths.

Dim new_bitmap As Bitmap = New Bitmap(850, 200)

Dim image_button As New System.Web.UI.WebControls.ImageButton

Thanks a lot

Rob

Nov 17 '05 #3
The May/June 2003 issue of CoDe (component developer magazine) had some
great articles on doing things of this nature. Basically, you need to use
the System.Drawing and System.Drawing.Imaging libraries. Use the source of
your image as an aspx page with a Response.ContentType = "image/jpeg" or
"image/gif" etc. I use something like this in a few of my pages <img
src="paint.aspx"> to create some dynamic images.

I don't want to violate copyright laws by repeating the source code that's
in there,
"Robert" <ro*******@gmx.com> wrote in message
news:09****************************@phx.gbl...
I need to add a dynamical!! generated bitmap to an image
button! What is the way to do it? The ImageButton offers
only the URL property. But this are physical file paths.

Dim new_bitmap As Bitmap = New Bitmap(850, 200)

Dim image_button As New System.Web.UI.WebControls.ImageButton

Thanks a lot

Rob

Nov 17 '05 #4

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

Similar topics

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...
8
by: Joergen Bech | last post by:
Suppose I have Dim bm As New Bitmap(16, 16,Imaging.PixelFormat.Format8bppIndexed) I cannot use Dim g As Graphics = Graphics.FromImage(bmdest) Dim hdc As IntPtr = g.GetHdc() as the...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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
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: 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...

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.