473,563 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in using asp.net stream graphic and image

hi
i want to put the name of my site in corner of my images
i've used from graphics and bitmap class and i have no problem with
putting the text
but it make problem with other works in my page
for example :
//-------------------------- begin
Bitmap bitMapImage = new
System.Drawing. Bitmap(Server.M apPath("image/" + 2 + ".jpg"));

Graphics graphicImage = Graphics.FromIm age(bitMapImage );
graphicImage.Sm oothingMode = SmoothingMode.A ntiAlias;
Rectangle rect = new Rectangle(1,1,5 0,50);
graphicImage.Dr awString("irank ohan.com", new Font("Arial", 12,
FontStyle.Bold) , SystemBrushes.W indowText, new Point(13, 27));
graphicImage.Dr awArc(new Pen(Color.White , 3), 90, 235, 150, 50, 0,
360);
Response.Conten tType = "image/jpeg";
bitMapImage.Sav e(Response.Outp utStream, ImageFormat.Jpe g);
//--------------------------- end
Label lb = new Label();
lb.Text = "milad";
Controls.Add(lb );
i wanna show information about the picture dynamically but it can't
be shown
why ?
Sep 11 '08 #1
5 1302
<mi********@gma il.comwrote in message
news:05******** *************** ***********@d45 g2000hsc.google groups.com...
hi
i want to put the name of my site in corner of my images
i've used from graphics and bitmap class and i have no problem with
putting the text
but it make problem with other works in my page
for example :
//-------------------------- begin
Bitmap bitMapImage = new
System.Drawing. Bitmap(Server.M apPath("image/" + 2 + ".jpg"));

Graphics graphicImage = Graphics.FromIm age(bitMapImage );
graphicImage.Sm oothingMode = SmoothingMode.A ntiAlias;
Rectangle rect = new Rectangle(1,1,5 0,50);
graphicImage.Dr awString("irank ohan.com", new Font("Arial", 12,
FontStyle.Bold) , SystemBrushes.W indowText, new Point(13, 27));
graphicImage.Dr awArc(new Pen(Color.White , 3), 90, 235, 150, 50, 0,
360);
Response.Conten tType = "image/jpeg";
bitMapImage.Sav e(Response.Outp utStream, ImageFormat.Jpe g);
//--------------------------- end
Label lb = new Label();
lb.Text = "milad";
Controls.Add(lb );
i wanna show information about the picture dynamically but it can't
be shown
why ?
Its not clear but my guess is that you believe that you can simply stream
out the image content as part of the rest of the HTML content of a page. Or
am I way off? If I am whats the Label code above doing?

You need to place this code in a .ashx file and have all your img srcs point
to it with the name of the image as a querystring parameter.

Make sure you configure the response cache headers correctly so that the
generated img can be cached clientside and hopeful by ASP.NET response
caching as well.
--
Anthony Jones - MVP ASP/ASP.NET

Sep 11 '08 #2
On Sep 11, 3:23*pm, "miladha...@gma il.com" <miladha...@gma il.com>
wrote:
hi
i want to put the name of my site in corner of my images
i've used from graphics and bitmap class and i have no problem with
putting the text
but it make problem with other works in my page
for example :
//-------------------------- *begin
*Bitmap bitMapImage = new
* * *System.Drawing .Bitmap(Server. MapPath("image/" + 2 + ".jpg"));

* Graphics graphicImage = Graphics.FromIm age(bitMapImage );
* graphicImage.Sm oothingMode = SmoothingMode.A ntiAlias;
* * * * Rectangle rect = new Rectangle(1,1,5 0,50);

* graphicImage.Dr awString("irank ohan.com", new Font("Arial", 12,
FontStyle.Bold) , SystemBrushes.W indowText, new Point(13, 27));
* graphicImage.Dr awArc(new Pen(Color.White , 3), 90, 235, 150, 50, 0,
360);
* Response.Conten tType = "image/jpeg";

* bitMapImage.Sav e(Response.Outp utStream, ImageFormat.Jpe g);
//--------------------------- end
*Label lb = new Label();
*lb.Text = "milad";
*Controls.Add(l b);

*i wanna show information about the picture dynamically but it can't
be shown
why ?
Because here you said that response is an image
Response.Conten tType = "image/jpeg";

As Anthony already mentioned you should separate the code for images
from the code for html layout.
Sep 11 '08 #3
hi to both of you
thanks for your answers
but i change the Response.Conten tType to text/html but no change was
happend
do you have sample about it ?
i wanna get my images url and information about it from Db
thanks for your helps
Sep 11 '08 #4
On Sep 11, 7:50*pm, "miladha...@gma il.com" <miladha...@gma il.com>
wrote:
hi to both of you
thanks for your answers
but i change the Response.Conten tType to text/html but no change was
happend
do you have sample about it ?
i wanna get my images url and information about it from Db
thanks for your helps
You have to move the code for images into ASPX, or ASHX "file".
I mean the code between

//-------------------------- begin
....
//--------------------------- end

Next, refer to that file as

<img src="MyImageFil e.aspx">

and do the rest.

Regarding Response.Conten tType. Sure, it's not only because of its
value. It does specify content type for the response for the browser
and browser will render the content on its own logic. In your example,
ContentType will not help because at the beginning you sent already
some piece of binary information and it cannot be rendered properly
together with HTML markup. This is the reason why you need to create a
separate web page that would serve for the binary output (your image)
and a regular ASP.NET webform to render the HTML markup.
Sep 12 '08 #5
"Alexey Smirnov" <al************ @gmail.comwrote in message
news:36******** *************** ***********@b1g 2000hsg.googleg roups.com...
On Sep 11, 7:50 pm, "miladha...@gma il.com" <miladha...@gma il.com>
wrote:
hi to both of you
thanks for your answers
but i change the Response.Conten tType to text/html but no change was
happend
do you have sample about it ?
i wanna get my images url and information about it from Db
thanks for your helps
>>>>>>>>
You have to move the code for images into ASPX, or ASHX "file".
I mean the code between

//-------------------------- begin
....
//--------------------------- end

Next, refer to that file as

<img src="MyImageFil e.aspx">

and do the rest.

Regarding Response.Conten tType. Sure, it's not only because of its
value. It does specify content type for the response for the browser
and browser will render the content on its own logic. In your example,
ContentType will not help because at the beginning you sent already
some piece of binary information and it cannot be rendered properly
together with HTML markup. This is the reason why you need to create a
separate web page that would serve for the binary output (your image)
and a regular ASP.NET webform to render the HTML markup.
>>>>>>>>>>
Use an .ashx, an aspx has way too much overhead that you're not going to
need.

--
Anthony Jones - MVP ASP/ASP.NET

Sep 12 '08 #6

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

Similar topics

2
4983
by: curwen | last post by:
Hi, I have problem to create a well formed xsl-fo document using images dynamically generated from an http request using this tag: <fo:external-graphic content-type="content-type:image/gif" src="controller.jsp?page=test&mode=image" /> doesn't work (it says a ';' is missing) the controller.jsp is sending a gif image to the browser and is
1
7128
by: jty202 | last post by:
I know alot of people have the problem with indexed pixel format. I hope someone can show me the solution to this.I am have problem with graphics with the following code giving the error: "A Graphics object cannot be created from an image that has an indexed pixel format." 'My code
4
3261
by: James A Taber | last post by:
Problem resizing image.(JPG) If i try to resize an img with horisontal=150 and vertical resolution=150 The quality of the target image is dramatically reduced. Source code is provided below. How can i solve this? What am i doing wrong? Thanx in advance -James A Taber
1
2835
by: Michael Stock | last post by:
Hi all, hopefully someone can tell me how to do this for a web server in C#: We have images in a folder you can't access over the net. So everytime we need to display an image from this folder, we need to us the following syntax: <img src="viewImage.aspx?imageID=/secretImages/image.jpg" border="0">
2
1477
by: Richard | last post by:
I each time get errors when I use an .bmp or ,.gif file as source but whenever I use a .jpg file it works perfect. Why is that? and how to fix it? I almost have no knowledge about the system.drawing and so I am in the dark about this. This is my code
7
2292
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving, the other in which I close the FileStream afterwards, although both return the same error. Here are the two versions of the code and the errors they...
23
5894
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine on most machines, on some machines I experience this problem: When loading the page a window pops up that asks if I want to open the document...
4
3251
by: Jean-François Michaud | last post by:
Hello, I've been looking at this for a bit now and I don't see what's wrong with the code. Can anybody see a problem with this? Here is an XSLT snippet I use. <xsl:template match="graphic"> <xsl:param name="path" /> <fo:block padding-after="12pt">
3
2125
by: André | last post by:
Hi, I want to include a graphic made in file2 into file. File must first send a value to file2 (with Response.Redirect) which will be used for the graphic. My problem is that only the graphic is rendered and not the content of file1. Thanks for help. André
0
7664
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...
0
7885
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. ...
0
8106
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...
1
7638
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...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3642
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...
1
2082
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
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
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...

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.