473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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
website.

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
code:

(index.aspx page_load event)
-------------------------
Dim bmp As New Drawing.Bitmap(32, 14,
Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim bmpButton As New Drawing.Bitmap("C:\button437.png")
Dim bmpRedX As New Drawing.Bitmap("C:\redx.png")
Dim g As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)

g.DrawImage(bmpButton, 0, 0)
g.DrawImage(bmpRedX, 0, 0)
bmp.MakeTransparent(bmp.GetPixel(0,0))
bmp.Save("C:\test.png", System.Drawing.Imaging.ImageFormat.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 2595

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

Similar topics

1
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...
2
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...
0
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...
7
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,...
0
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...
2
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
0
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...
0
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...
6
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.