i have button have this code under just drawing arabic text on image
Dim bmp As New Bitmap(500, 500)
Dim gs As Graphics = Graphics.FromImage(bmp)
Dim f As New Font(FontFamily.GenericSansSerif.ToString, 13)
Dim p As New Point(10, 10)
Try
gs.DrawString("some arabic text goes here", f, Brushes.Bisque, p)
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Jpeg)
Catch ex As Exception
MsgBox(ex.Message)
End Try
gs.DrawString("some arabic text goes here", f, Brushes.Bisque, p);
Response.ContentType = "image/jpeg";
MemoryStream ms = new MemoryStream();
bmp.Save(ms, Drawing.Imaging.ImageFormat.Jpeg);
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, (int)ms.Length);
ms.Dispose();
Response.BinaryWrite(buffer);
Sorry it's in C#, but the VB.NET code will follow similar lines.
In that case I would try putting that code in another file and update your image src attribute to point at that file. You could add a query string to the src as well, so you could specify the language required, e.g.
<img src="imagewithtext.aspx?lang=en" alt="" />
Otherwise I think that you're going to have trouble changing the HTTP header from the code that updates your UpdatePanel. When you make a request this way, the code is expecting to send text/html back to the client browser in the HTTP response - not image
(binary) data.
seco
Member
83 Points
141 Posts
error message when drawing text on image
Jan 24, 2008 02:29 PM|LINK
HI
i have button have this code under just drawing arabic text on image
Dim bmp As New Bitmap(500, 500)
Dim gs As Graphics = Graphics.FromImage(bmp)
Dim f As New Font(FontFamily.GenericSansSerif.ToString, 13)
Dim p As New Point(10, 10)
Try
gs.DrawString("some arabic text goes here", f, Brushes.Bisque, p)
Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Jpeg)
Catch ex As Exception
MsgBox(ex.Message)
End Try
i get error message as on the image
[URL=http://img136.imageshack.us/my.php?image=41122658tc0.jpg][IMG]http://img136.imageshack.us/img136/8224/41122658tc0.th.jpg[/IMG][/URL]
any help
thanks in adavnce.
Brent Jenkins
Participant
958 Points
177 Posts
Re: error message when drawing text on image
Jan 24, 2008 02:45 PM|LINK
Try adding Response.Clear() before your Response.ContentType = "image/jpeg" call.
Director, Vale Web Design Ltd
Web: www.valewebdesign.co.uk
LinkedIn: http://www.linkedin.com/in/valewebdesign
seco
Member
83 Points
141 Posts
Re: error message when drawing text on image
Jan 24, 2008 04:40 PM|LINK
thanks for reply
i add response.clear() and still gives me the same message
any idea?
Brent Jenkins
Participant
958 Points
177 Posts
Re: error message when drawing text on image
Jan 24, 2008 06:31 PM|LINK
Try modifying your code to something like:
gs.DrawString("some arabic text goes here", f, Brushes.Bisque, p); Response.ContentType = "image/jpeg"; MemoryStream ms = new MemoryStream(); bmp.Save(ms, Drawing.Imaging.ImageFormat.Jpeg); byte[] buffer = new byte[ms.Length]; ms.Read(buffer, 0, (int)ms.Length); ms.Dispose(); Response.BinaryWrite(buffer); Sorry it's in C#, but the VB.NET code will follow similar lines.Director, Vale Web Design Ltd
Web: www.valewebdesign.co.uk
LinkedIn: http://www.linkedin.com/in/valewebdesign
seco
Member
83 Points
141 Posts
Re: error message when drawing text on image
Jan 24, 2008 08:06 PM|LINK
i forget to say that the above code i wrote works fine when there is no update panel
Brent Jenkins
Participant
958 Points
177 Posts
Re: error message when drawing text on image
Jan 24, 2008 09:41 PM|LINK
In that case I would try putting that code in another file and update your image src attribute to point at that file. You could add a query string to the src as well, so you could specify the language required, e.g.
<img src="imagewithtext.aspx?lang=en" alt="" />
Otherwise I think that you're going to have trouble changing the HTTP header from the code that updates your UpdatePanel. When you make a request this way, the code is expecting to send text/html back to the client browser in the HTTP response - not image (binary) data.
Director, Vale Web Design Ltd
Web: www.valewebdesign.co.uk
LinkedIn: http://www.linkedin.com/in/valewebdesign
Jin-Yu Yin -...
All-Star
21280 Points
1824 Posts
Re: error message when drawing text on image
Jan 30, 2008 06:41 AM|LINK
Hi,
Thank you for your post!
You cann't modify the Response manually in Ayncpostback. You should place that logic to another page, then do it like this in your current page:
protected void Button1_Click(object sender, EventArgs e)
{
ImageMap1.ImageUrl = "Default25.aspx?oIP=C:\\Documents and Settings\\v-jyyin\\Desktop\\IMG\\c4960543c39f4f0c71b53bf27aa34e65.jpg";
}
A simple of this is here: http://forums.asp.net/p/1120067/1756358.aspx#1756358
If you have further questions,let me know!
Jin-Yu Yin
Microsoft Online Community Support