473,836 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem system.drawing transparent web images

Here's the scenario:

I've got a whole bunch (for the sake of argument, let's say thousands) of
different little 32x14 .png files that act as buttons all over a very large

Each button image has 4 transparent pixels; the upper left, upper right,
lower left & lower right. This is to help give the otherwise square button
graphic a slightly rounded look to it.

Now sometimes, we want to display any given button with a red x over it, to
designate to the user the button is unavailable (or not applicable, or
whatever - it can have various meanings).

So instead of creating thousands of copies of the buttons with x's over them
in photoshop, I created 1 transparent .png file of an otherwise totally
transparent red x, which at run time and as needed, "layer" over the
appropriate button image. I then output a new "x-ed out" version of the
button with a new name.

Which, in testing, is *almost* working perfectly using this code simple

(index.aspx page_load event)
Dim bmp As New Drawing.Bitmap( 32, 14,
Drawing.Imaging .PixelFormat.Fo rmat32bppArgb)
Dim bmpButton As New Drawing.Bitmap( "C:\button437.p ng")
Dim bmpRedX As New Drawing.Bitmap( "C:\redx.pn g")
Dim g As Drawing.Graphic s = Drawing.Graphic s.FromImage(bmp )

g.DrawImage(bmp Button, 0, 0)
g.DrawImage(bmp RedX, 0, 0)
bmp.MakeTranspa rent(bmp.GetPix el(0,0))
bmp.Save("C:\te st.png", System.Drawing. Imaging.ImageFo rmat.Png)

Label1.Text = "<img src=test.png>"

The red X image is very nicely blended over the top of the button image,
producing exactly the effect we are looking for... almost.

Remember the upper left, upper right, lower left and lower right pixels that
were transparent in the original button file? They are now WHITE, and I
can't seem to make them transparent anymore. I've tried to use the
MakeTransparent method with color.white, even referencing the upper-left
pixel directly as in the above code sample, just in case it wasn't quite
equal to white, but to no avail. The button is now nicely visually X-ed out
with the red X graphic overlay, however the button is no longer 'round'
looking and to add insult to injury, has very conspicuous white pixels at
each of it's 4 corners.

If I open test.png in photoshop 6.0, photoshop shows the 4 corner pixels as
transparent. Is this a web pallete thing? I've tried various methods but
remain stumped.
Nov 17 '05 #1
0 2630

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

Similar topics

by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to create a form, a button (Button1) and an Picture Box (picBox). "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image with the white background, which will turn to transparent. The most important thing here is that the TIFF image...
by: pei_world | last post by:
Hi I want to create a image with multiple layers on top. the background color of each layer should be transparent except the last one, hence I can only see the drawed items on such layers. can anyone tell me whether or not C# allow to do this? pei_world
by: Brian Henry | last post by:
Ok whats going on here... got a couple problems... this is relevant now to this group since .NET 2.0 is finally RTM 1) draws really slow when making it a large form (resizing speed is jerky) to a res from 100x100 to 1280x1024 once it gets above 500x500 it starts jerking you can see the screen refreshing as it paints 2) sometimes the background selection when you select multiple items then move the mouse around on the screen dissapear...
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 each return (NOTE: I rebooted immediately before running each of these versions so that I knew they...
by: VorTechS | last post by:
I'm having a problem with an inherited label, applying text rotation to aligned text. If text rotation is applied to the aligned text, the alignment goes 'nuts'. I can find no logic to what is happening. I've built the following code from several examples on the web, if you remove the rotation then alignment works fine: Imports System.ComponentModel
by: JR | last post by:
Hi, I need to change the notifyicon in a countdown. after about 3000-5000 times there is an error. Here is all the code. what is wrong please help
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
by: vladimir.knobel | last post by:
Hi everyone, I'm working in a MCMS 2002 site and for a template I need to create images on the fly. The image format of choice is PNG because this images had to have a transparent background and .NET doesn't go very well with transparent GIFs (black background generated instead). So everything when more or less fine until I've tested my beautifully anti aliased PNG images in IE 6 there they are showing a horrendous washed blueish...
by: HristiyanVasilev | last post by:
Hello there ! I'm developing a Windows appliciation that involves so called "Transparent Controls". As you would probably know, the only ( as far as i know ) way to achieve a fully transparent control in C# is to add the so called "Transparent style" to your control ("WS_EX_TRANSPARENT"). There are numerous articles how to achieve this and the method is ALMOST always one and the same: protected override CreateParams CreateParams { get ...
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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: 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: 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
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.