Hi,
I have a problem when I draw a transparent gif picture. I have an existing
transparent gif picture, i want to modify the gif and save it to
reponse.outstream. But the picture always keep black backgroup. Can anyone
give me some suggestions?
Following is my code.
System.Drawing.Image img =
System.Drawing.Image.FromFile(Server.MapPath("imag es\\menubutton.gif"));
bmWidth = img.Width;
bmHeight = img.Height;
Bitmap bm = new Bitmap(bmWidth, bmHeight);
Graphics g = Graphics.FromImage(bm);
stringSize = g.MeasureString(menuname, menuFont);
g.DrawImage(img, 0, 0);
g.DrawString(menuname, menuFont, new SolidBrush(Color.Black),
(bmWidth - stringSize.Width) / 2, (bmHeight - stringSize.Height) / 2);
Response.ContentType="image/gif";
bm.Save(Response.OutputStream, ImageFormat.Gif);
Thanks
Mike 1 1510
You have to explicity set transparent color.
See Bitmap.MakeTransparent
It might help.
George.
"Minhua Fu" <mi*******@sympatico.ca> wrote in message
news:yb********************@news20.bellglobal.com. .. Hi,
I have a problem when I draw a transparent gif picture. I have an existing transparent gif picture, i want to modify the gif and save it to reponse.outstream. But the picture always keep black backgroup. Can anyone give me some suggestions?
Following is my code.
System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("imag es\\menubutton.gif"));
bmWidth = img.Width;
bmHeight = img.Height;
Bitmap bm = new Bitmap(bmWidth, bmHeight);
Graphics g = Graphics.FromImage(bm);
stringSize = g.MeasureString(menuname, menuFont);
g.DrawImage(img, 0, 0);
g.DrawString(menuname, menuFont, new SolidBrush(Color.Black),
(bmWidth - stringSize.Width) / 2, (bmHeight - stringSize.Height) / 2);
Response.ContentType="image/gif";
bm.Save(Response.OutputStream, ImageFormat.Gif); Thanks
Mike
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Starlite |
last post by:
I am using Microsoft visual c++ 6, and I want to draw a shape (say a
rectangle) on a view. The code that I have used is below, but this draws a
solid -filled rectangle, what I want is a displayed...
|
by: DraguVaso |
last post by:
Hi,
I have an inherited DataGrid, that does lots of extra stuff. For exemple
drawing a backgroundimage in every cell. The problem is that it's taking too
much time (using gdi+), so I want to do...
|
by: felix |
last post by:
Hi,
I have an Image that is drawn with Graphics.DrawImage(..). What I want
to do is drawing it with a given transparency, e.g. at an alpha of only
180 instead of 255.
How am I doing that?!?!?...
|
by: Robert W. |
last post by:
I've successfully implemented code to change a form's background to a nice
blue gradient. It looks great!
But I'm having problems adding controls with transparent backgrounds to the
form. ...
|
by: Carsten Klotz |
last post by:
Hi,
I've set the TransparencyKey of a form to black. That means, all black
pixel will be shown transparent within the drawing content of that form. If
I set the background to black, I can see...
| |
by: Rich |
last post by:
Hello,
I need to draw some text on a form. No problem
....
e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat)
My problem is that I want to draw the text on top of some...
|
by: Niu Kun |
last post by:
Dear all,
I'm planning to draw some overlapped pictures on a tabpage.
I use PictureBox control. And the picture seems well at first.
But when I try to draw a PictureBox on the other.
The...
|
by: Niu Kun |
last post by:
Dear all,
I'm trying to draw many overlapped PNG files with transparent background
in imagebox control.
But the transparent background in this control is rendered as the main
control's...
|
by: Phil |
last post by:
I would like to draw some text which will be in front of any other controls,
but without obscuring them completely. If I use DrawString in the form's
Paint handler the text is always behind, not in...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |