I keep getting my string inside a black box with this code.
I would like to make the background transparent. Any help on this will
be appreciated very much.
'**** BEGIN CODE ****
Try
Dim NewFont As New Font(fg.Font.Fo ntFamily, 10, FontStyle.Regul ar)
Dim g As Graphics
Dim pic As Bitmap = New Bitmap(20, 20,
imaging.PixelFo rmat.Format24bp pRgb)
g = Graphics.FromIm age(pic)
g.Clear(Color.T ransparent)
g.DrawString("H ", NewFont, Brushes.Blue, 0, 0)
Dim st As New System.IO.Memor yStream
pic.Save(st, System.Drawing. Imaging.ImageFo rmat.Bmp)
Dim img As Image = Image.FromStrea m(st)
pct.Image = img
Catch exc As Exception
Stop
End Try
'**** END CODE ****
Kalvin 2 8184
Hi,
Try something like this.
Try
Dim g As Graphics
Dim pic As Bitmap = New Bitmap(20, 20, Imaging.PixelFo rmat.Format24bp pRgb)
g = Graphics.FromIm age(pic)
g.Clear(Color.Y ellow)
g.DrawString("H ", Me.Font, Brushes.Blue, 0, 0)
pic.MakeTranspa rent(Color.Yell ow)
'Dim st As New System.IO.Memor yStream
'pic.Save(st, System.Drawing. Imaging.ImageFo rmat.Bmp)
'Dim img As Image = Image.FromStrea m(st)
PictureBox1.Ima ge = pic
Catch exc As Exception
Stop
End Try
Ken
---------------------------
"Kalvin" <kt***@streck.c om> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
I keep getting my string inside a black box with this code.
I would like to make the background transparent. Any help on this will
be appreciated very much.
'**** BEGIN CODE ****
Try
Dim NewFont As New Font(fg.Font.Fo ntFamily, 10, FontStyle.Regul ar)
Dim g As Graphics
Dim pic As Bitmap = New Bitmap(20, 20,
imaging.PixelFo rmat.Format24bp pRgb)
g = Graphics.FromIm age(pic)
g.Clear(Color.T ransparent)
g.DrawString("H ", NewFont, Brushes.Blue, 0, 0)
Dim st As New System.IO.Memor yStream
pic.Save(st, System.Drawing. Imaging.ImageFo rmat.Bmp)
Dim img As Image = Image.FromStrea m(st)
pct.Image = img
Catch exc As Exception
Stop
End Try
'**** END CODE ****
Kalvin
Thank you very much for your reply. I did try that, but what I wind up
with is still a black background. When I use the
pic.clear(color .yellow) line without the
pic.MakeTranspa rent(Color.Yell ow) line, I get a yellow background, as
soon as I add the maketransparent call execute, I get the black
background again. I did find that if I don't save it to the
memoryStream, then the background is transparent. Is there something
with the memory stream that is going to color the background?
Kalvin
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul Schnitter |
last post by:
Update:
My custom control is based on the article
"Creating Visual Basic .NET controls from scratch"
in "Adventures in .NET" on MSDN.
It is designed to be a replacement for the VB6 shape
control.
My control draws a shape (circle, square, rectangle ...)
|
by: Konrad Den Ende |
last post by:
I have a function returning a string but the problem is that the
color of it is blue which suits me well for some pages but not for
others. Is it possible to "feel" what the color of the background
in the current document is and set the color of the output accordingly? The
background will be an image, in most cases.
--
Kindly
Konrad
|
by: Chris Auer |
last post by:
I have been banging my head for a couple of hours now. No matter what I
do the color that I make transparent is black. Here is the code I am
using from MSDN. I have tried bitmaps, jpegs, gifs and new bitmaps
created in code, but I cant get any image to go transparent. Thanks if
you can help.
// Create a Bitmap object from an image file.
Bitmap myBitmap = new
Bitmap(System.Web.HttpContext.Current.Server.MapPath("resources/img/")
|
by: Robert W. |
last post by:
In my Winforms app I'm trying to get an image's background to appear
transparent on a form that has a gradient background. So I added a
PictureBox and then attempted to add a custom paint command for the
PictureBox. But it's not working. Here's the code I've written:
public void InitializeLinearGradients()
{
this.Paint += new PaintEventHandler(PaintClient);
this.SizeChanged += new EventHandler(SizeClient);
pictureLogo.Paint += new...
|
by: Grahammer |
last post by:
Is it possible to set the background of a usercontrol as transparent?
I tried setting the background image of the usercontrol to a transparent
GIF, but that caused MAJOR problems.
I'm making some controls that aren't rectangular and it won't be pretty if I
end up with a grey rectangle behind each one.
http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskGivingYourControlTransparentBackground.asp?frame=true
| |
by: Martin |
last post by:
I'm using the code show below (in VB.Net 2003) to create an image. I
want to save this image to a .PNG file such that when I subsequently
display it as part of a web page, the background of the image will be
transparent.
This test/learning code simply draws a diagonal green line across a
square box. When I display the resulting file on a web page, I want
only the line itself to be visible but what is happening is that the
entire "box"...
|
by: Eric |
last post by:
I created a gradient form and want the background of the labels to take on
the same color pattern as the parent form. Is this easily possible?
Thanks
|
by: Brian Ward |
last post by:
I am looking for a simple way to set the image transparency in a PictureBox.
I have a moving PictureBox containing a graphic image .. moving by
incrementing its Left property.
The background however shows white as the PictureBox moves but I want it
to be transparent.
The PictureBox BackColor is set to Transparent .. but no affect. I have
used PhotoShop to make the image background transparent .. again no
affect.
If I make the image a...
|
by: Bryon |
last post by:
My current code paints a rectangular area at the top (under the menu and
tool strip) and bottom (top of the status strip) of the main form with a
linear gradient. The problem is that when the form is resized or maximized
for that matter, the form still displays the last areas that were painted
with gradient. Basically the form does not erase the last graphics that
were painted to the form and just paints over it with the new. My code is...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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?
| |