473,378 Members | 1,438 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.

How can I get an image with webclient and display on calling asp.net page?

Hi, using this code I pieced together from others:

<%@ Page language="c#" Debug="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
Bitmap bkGroundImg = null;
Bitmap userImg = null;
Graphics bkImgGraphics = null;
Graphics userImgGraphics = null;

void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";

string url = Request.QueryString["url"];
string trans = Request.QueryString["trans"];
trans ="0";
// Response.Write("url: "+url);
// Response.Write("<userImgr>trans:
"+(float)DouuserImgle.Parse(trans));

WebClient client = new WebClient();
Stream stream = client.OpenRead(trans);

userImg = new Bitmap(stream);
userImg = new Bitmap(userImg, 100, 100);
stream.Close();

bkGroundImg = new Bitmap(100 + 10, 100 + 10);

bkImgGraphics = Graphics.FromImage(bkGroundImg);
userImgGraphics = Graphics.FromImage(userImg);
bkImgGraphics.DrawImage(userImg, 2, 2);

bkGroundImg.Save(Response.OutputStream, ImageFormat.Jpeg);
}
</script>

I can get this to work fine. The page produces the image.

I want to use the output of the page, however, to populate an Image
Control on another page. I am trying this:

Image1.ImageUrl = "GetImage.aspx";

but it doesn't return anything to the calling page. No errors, just no
image. What am I doing wrong?Thank you for any help.

Oct 11 '06 #1
1 1853
nevermind. sorry. I spelled the .aspx page wrong.
ne***********@gmail.com wrote:
Hi, using this code I pieced together from others:

<%@ Page language="c#" Debug="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
Bitmap bkGroundImg = null;
Bitmap userImg = null;
Graphics bkImgGraphics = null;
Graphics userImgGraphics = null;

void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";

string url = Request.QueryString["url"];
string trans = Request.QueryString["trans"];
trans ="0";
// Response.Write("url: "+url);
// Response.Write("<userImgr>trans:
"+(float)DouuserImgle.Parse(trans));

WebClient client = new WebClient();
Stream stream = client.OpenRead(trans);

userImg = new Bitmap(stream);
userImg = new Bitmap(userImg, 100, 100);
stream.Close();

bkGroundImg = new Bitmap(100 + 10, 100 + 10);

bkImgGraphics = Graphics.FromImage(bkGroundImg);
userImgGraphics = Graphics.FromImage(userImg);
bkImgGraphics.DrawImage(userImg, 2, 2);

bkGroundImg.Save(Response.OutputStream, ImageFormat.Jpeg);
}
</script>

I can get this to work fine. The page produces the image.

I want to use the output of the page, however, to populate an Image
Control on another page. I am trying this:

Image1.ImageUrl = "GetImage.aspx";

but it doesn't return anything to the calling page. No errors, just no
image. What am I doing wrong?Thank you for any help.
Oct 11 '06 #2

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

Similar topics

1
by: Dave | last post by:
To open needed site I have to give my ID and a password. I can use webclient.downloadFile() to load an html text. Is there a way to display this site using an webclient object before calling...
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...
4
by: Marc Pelletier | last post by:
Hello, I have a class (TideClass) which creates a bitmap image as one of its functions. I want to create a page which has this image embedded amongst some text. I know that I have to stream the...
1
by: Fahad Aijaz | last post by:
Hi, I am trying to display a Png image via ASP .NET. I get the image from the stream, creates the Bitmap, set the content type to Image/Png, but it give an error. If I set the content type to...
3
by: ACaunter | last post by:
Hi there, I was wondering if there was a way to crop a peice of an ASP.Net Image, allowing the user to zoom in on only a section of the picture?? any help would be appreciated!! thanks --...
2
by: CDWaddell | last post by:
I'm trying to write some code to validate if an image is present on the server. If the image is missing then I want to display out noimage.gif file. I have a website that has thousands of...
4
by: B Squared | last post by:
I'm trying to pass a filename (which is a jpeg image) to a php function / file so that it will display. I know that its simple to get PHP to display an image hardcoding in the filename. For...
3
by: Giggi | last post by:
Hi! I need to pass some strings via an HTTP POST from page1 (in my app) to a page on another server. I stored my data in a NameValueCollection and then sent it using WebClient.UploadValues....
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
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
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: 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
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...
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.