***Scenario ...
I have a DataList with a hyperlink WebControl in the Item Template.
I want to display a 64x64 image in the Hyperlink and set the NavigateURL to
the full size image.
***Source Data Item for Databinding is a class with 2 props ...
URL
Description
***MyMainPage.a spx Page_Load Code ...
Dim myImages As ArrayList = New ArrayList
myImages.Add(Ne w ImageItem(URL As String =
"http://localhost/mywebapp/images/bigpic.bmp", Description As String = "My
bigpic")
DataList1.DataS ource = myImages
DataList1.DataB ind()
***Databing Code for Hyperlink in DataList1 on MyMainPage.aspx ...
*Tooltip = [DataBinder.Eval (Container.Data Item, "Descriptio n")
*NavigateURL = [DataBinder.Eval (Container.Data Item, "URL")
*ImageURL = ["ImageProcessor .aspx?filename= " &
DataBinder.Eval (Container.Data Item, "URL") & "&width=64&heig ht=64"]
***ImageProcess or.aspx Page_Load Code (Imports System.Drawing) ...
Dim imagePath As String = Request.Params( "filename")
Dim requestedWidth As Integer = Request.Params( "width")
Dim requestedHeight As Integer = Request.Params( "height")
Dim sourceImage As Image = Image.FromFile( imagePath)
Dim newImage As Bitmap = New Bitmap(requeste dWidth, requestedHeight ,
Imaging.PixelFo rmat.Format24bp pRgb)
newImage.SetRes olution(sourceI mage.Horizontal Resolution,
sourceImage.Ver ticalResolution )
Dim gr As Graphics = Graphics.FromIm age(newImage)
gr.Interpoloati onMode = Drawing2D.Inter polationMode.Hi ghQualityBicubi c
gr.DrawImage(so urceImage, _
New Rectangle(0, 0, requestedWidth, requestedHeight ), _
New Rectangle(0, 0, sourceImage.Wid th, sourceImage.Hei ght), _
GraphicsUnit.Pi xel)
gr.Dispose()
Response.Conten tType = "image/bmp"
newImage.Save(R esponse.OutputS tream, Imaging.ImageFo rmat.Bmp)
=============== =============== ====
When I run this code I get the hyperlink control with a 'X' in it because it
could not load
an image, but the link itself IS active and correctly takes me to a view of
the full size image.
I've tested the resizing code used in ImageProcessor. aspx on a Windows Form
with a
couple of picture boxes and all seems to be fine, so I conclude that my
problem lies in
how I am writing the resized image to the Response OutputStream (new ground
for me).
So, if anyone can spot my mistake I'd be very grateful.
Thanks,
Neil 1 2931
Sorted it.
Just read elsewhere that Response.Output Stream only likes GIFs or JPEGs, not
BMPs.
So I Changed ...
Response.Conten tType = "image/bmp"
newImage.Save(R esponse.OutputS tream, Imaging.ImageFo rmat.Bmp)
To ...
Response.Conten tType = "image/jpeg"
newImage.Save(R esponse.OutputS tream, Imaging.ImageFo rmat.Jpeg)
and all is just dandy!
Cheers,
Neil
"Neil Woodvine" <nR************ ****@btEinternM et.cEom> wrote in message
news:ce******** **@titan.btinte rnet.com... ***Scenario ... I have a DataList with a hyperlink WebControl in the Item Template. I want to display a 64x64 image in the Hyperlink and set the NavigateURL
to the full size image.
***Source Data Item for Databinding is a class with 2 props ... URL Description
***MyMainPage.a spx Page_Load Code ... Dim myImages As ArrayList = New ArrayList myImages.Add(Ne w ImageItem(URL As String = "http://localhost/mywebapp/images/bigpic.bmp", Description As String = "My bigpic") DataList1.DataS ource = myImages DataList1.DataB ind()
***Databing Code for Hyperlink in DataList1 on MyMainPage.aspx ... *Tooltip = [DataBinder.Eval (Container.Data Item, "Descriptio n") *NavigateURL = [DataBinder.Eval (Container.Data Item, "URL") *ImageURL = ["ImageProcessor .aspx?filename= " & DataBinder.Eval (Container.Data Item, "URL") & "&width=64&heig ht=64"]
***ImageProcess or.aspx Page_Load Code (Imports System.Drawing) ... Dim imagePath As String = Request.Params( "filename") Dim requestedWidth As Integer = Request.Params( "width") Dim requestedHeight As Integer = Request.Params( "height") Dim sourceImage As Image = Image.FromFile( imagePath) Dim newImage As Bitmap = New Bitmap(requeste dWidth, requestedHeight , Imaging.PixelFo rmat.Format24bp pRgb) newImage.SetRes olution(sourceI mage.Horizontal Resolution, sourceImage.Ver ticalResolution ) Dim gr As Graphics = Graphics.FromIm age(newImage) gr.Interpoloati onMode = Drawing2D.Inter polationMode.Hi ghQualityBicubi c gr.DrawImage(so urceImage, _ New Rectangle(0, 0, requestedWidth, requestedHeight ), _ New Rectangle(0, 0, sourceImage.Wid th, sourceImage.Hei ght), _ GraphicsUnit.Pi xel) gr.Dispose() Response.Conten tType = "image/bmp" newImage.Save(R esponse.OutputS tream, Imaging.ImageFo rmat.Bmp)
=============== =============== ==== When I run this code I get the hyperlink control with a 'X' in it because
it could not load an image, but the link itself IS active and correctly takes me to a view
of the full size image.
I've tested the resizing code used in ImageProcessor. aspx on a Windows
Form with a couple of picture boxes and all seems to be fine, so I conclude that my problem lies in how I am writing the resized image to the Response OutputStream (new
ground for me).
So, if anyone can spot my mistake I'd be very grateful.
Thanks, Neil
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David W. Simmonds |
last post by:
I have a DataList control that has an Image control in the ItemTemplate. I
would like to resize the image that goes into that control. I have a series
of jpg files that are full size, full resolution (ie. large). I have a
database that contains references to the pictures. Currently I have to
resize the jpgs manually, and then point the ImageUrl property at that jpg
using databinding. This works fine. I would like to avoid the resizing step...
|
by: Stephen |
last post by:
Hi,
I am using an Access database (OLE Object) and storing Image as a bytes
after streaming. I am able to read it back as a stream and display it on the
browser using the following code:
Response.OutputStream.Write(fileData, 0, fileData.Length)
it displays on the browser as an image, but I want to display it in an Image
(web control image) so that I can manipulate its size.
How can I do this?
|
by: dgk |
last post by:
I have an app that has many subdirectories containing one or more
images (jpg, gif, bmp). When the user selects a directory, my plan is
to show the images if there are only one or two, or show thumbnails if
there are more and allow the user to click on each thumbnail to view
it full size.
Right now I'm just sticking an <IMG> tag for each image into a literal
control. It works fine but the images are huge which surprised me. I
really...
|
by: Brad |
last post by:
I have code which takes an image, uploaded from a web page, and saves it to
a database. Now I want to always resize an uploaded image before it is
saved to the database. My code to resize is below and of course it's not
working properly because my web page which displays the resulting image from
the database is not showing the image. I **think** the problem is in my
converting the bitmap back to a byte array. If I change my code back...
|
by: Neil Woodvine |
last post by:
***Scenario ...
I have a DataList with a hyperlink WebControl in the Item Template.
I want to display a 64x64 image in the Hyperlink and set the NavigateURL to
the full size image.
***Source Data Item for Databinding is a class with 2 props ...
URL
Description
***MyMainPage.aspx Page_Load Code ...
| |
by: David Lozzi |
last post by:
Howdy,
I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!
Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
|
by: rob lynch |
last post by:
I am having a real problme returning an image from a directory that isn't
under my webserver..
I.E.
the image is on my F: drive but my website exists in the D: and I have no
intention of adding the F: drive or any of it's subdirectorys to my website.
The problem relates to the image / response.type..
I am reading a jpg and my web app is returning a bmp :(
|
by: tshad |
last post by:
I am trying to set up an Image authorization where you type in the value
that is in a picture to log on to our site.
I found a program that is supposed to do it, but it doesn't seem to work.
It should put a blue and yellow box on the page with "This is a test" as
part of the picture. But what I get is a broken Gif.
The other problem is that I can't view the source???? The view source is
disabled for this page. What causes this?
|
by: Mark S. |
last post by:
Hello,
On a high volume page we have the following JavaScript:
img = new Image()
img.src = 'http://myserver.com/count.aspx?x=1';
and it works fine, but now we've added:
img.onload = myImgLoaded
and it fails on IE and FF. The reason being it's not returning a proper
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |