473,666 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image drop shadow

I have a 200x200 PNG file which has an Alpha layer.

What I would now like is a 200x200 image that is completely black, but with
the same alpha mask. This is so that I can use it as a drop shadow behind
the PNG when drawing to a target image.

I cannot see how I can draw to a Graphics without destroying the Alpha. Any
hints?
Thanks

Pete
Jun 27 '08 #1
2 7920
On Wed, 16 Apr 2008 05:02:10 -0700, Peter Morris <mrpmorris at gmail dot
<"com>"wrote :
I have a 200x200 PNG file which has an Alpha layer.

What I would now like is a 200x200 image that is completely black, but
with
the same alpha mask. This is so that I can use it as a drop shadow
behind
the PNG when drawing to a target image.

I cannot see how I can draw to a Graphics without destroying the
Alpha. Any
hints?
I think there's a small chance that setting the Graphics.Compos itingMode
to "over" might be helpful. Perhaps with some pre-initialization of the
target Bitmap into which you're drawing or something. But I haven't
played with it enough to know for sure, and it really depends on what
Microsoft means by "blend".

Other than that, you may have to use Bitmap.LockBits () to get at the
actual image data directly, and then do the conversion yourself
(basically, leave the alpha alone and set the RGB to whatever is
appropriate for your needs...like [0, 0, 0] for a black shadow, for
example.

Pete
Jun 27 '08 #2
Unfortunately that didn't work.

private void button1_Click(o bject sender, EventArgs e)
{
Image i =
Image.FromFile( @"C:\Data\Custo merProjects\Int eevo\Projects\A lterEgo\Charact erEditor\Sample s\Lady1\Lad__00 01.png");
Image shadow = (Image)i.Clone( );
Image resultImage = new Bitmap(i.Width, i.Height);
Graphics resultCanvas = Graphics.FromIm age(resultImage );
Graphics shadowCanvas = Graphics.FromIm age(shadow);

//Need to preserve the alpha in this next line
shadowCanvas.Fi llRectangle(Bru shes.Black, new Rectangle(0, 0, 200, 200));

resultCanvas.Dr awImage(shadow, new Point(0, 0));
pictureBox1.Ima ge = resultImage;
}
Does anyone have any ideas?
Jun 27 '08 #3

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

Similar topics

0
2272
by: james | last post by:
Hi guys! I´ve got a centerd table on my site with a black 1 pixel border. What i would like to do is to add a drop shadow to the table. Anyone know if it's possible to create a drop shadow for a table? Does anyone has an example? Thanks, James
3
2780
by: surajitkhan | last post by:
Hi Can anyone tell me how to make a drop shadow for a table or td through css. I dont want to use any image. I want it done through background color. Thanks Surajit
3
33763
by: Pawel | last post by:
Hi, What is the best way to add a drop shadow around table borders with just html and css that looks nice and works in most browsers? I have written a program for making online web site calendars, and I want to add a drop shadow effect around the calendars, without having to use images.
1
4166
by: Hardy Wang | last post by:
Hi, I found a piece of code to add drop shadow to a photo like below, after I save the image, it is actually a BMP file even though I specify a JPG file extension (see http://img140.imageshack.us/my.php?image=resized11wz.jpg). If I force to save in JPG format (see the commented line), then the whole shadow is a messup (see http://img70.imageshack.us/my.php?image=resized29cy.jpg). I am just wandering are there any attributes / formats...
16
14553
by: eholz1 | last post by:
Hello CSS group, I saw a beautiful effect that I would like to use either by CSS or using photoshop to create the image/effect (maybe even imagemagick) the site address is: http://victor.hasselblad.com/. the lead image here is a white photograph (jpeg) on a white background, with a shadow like effect around the entire image. In this case the shadow effect is part of the jpeg, and not
1
7323
by: Peter Bengtsson | last post by:
I love the dropshadow effect I managed to make with this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474116 Here's what it can look like: http://www.peterbe.com/test/188-tequilacat.2.jpg It takes a background as a parameter but it's just a colour. What I want is to put the image on top of another but doing so with a dropshadow. I guess the solution would be something like putting the dropshadow on the first image...
3
3400
by: mechphisto | last post by:
So I'm Web browsing and I go to rottentomatoes.com, and I see something interesting: If you go to any movie page, you'll see on the top left, above and below the film poster image, the names of a couple of the actors and the director. Those names are orangeish, but with a black drop shadow! And it's just text, not images. I could really use that technique on my Web site where I have some text over an image that needs to "pop" and be in...
9
2375
by: adastic | last post by:
Any idea how this guy does his AJAX drop shadows (see the post title "New Year New Site" in blue with the light gray in larger font offset from it): http://www.dhtmlnirvana.com/blog/archives/New-Year-New-Site.html ...and could this technique be used to create a more conventional same-font/slightly offset text drop shadow? I see from this post that sometimes text drop shadows are done in a way that leaves the text showing up double in...
0
1540
by: Peter Morris | last post by:
A while ago I asked how to replace an image with a solid black colour whilst preserving the alpha mask/channel, this was so that I could automatically create a drop shadow. For future reference of anyone seeking the answer here it is: private static void MakeShadow(Bitmap dest) { BitmapData bits = dest.LockBits(new Rectangle(0, 0, dest.Width, dest.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite,...
0
8356
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,...
0
8871
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6198
isladogs
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...
0
5664
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();...
0
4198
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...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
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.