473,405 Members | 2,294 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,405 software developers and data experts.

Fast image drop shadow - answer + new question

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,
System.Drawing.Imaging.PixelFormat.Format32bppArgb );
IntPtr bottomScanLine = bits.Scan0;
int bytesPerRow = bits.Width * 4;

unsafe
{
byte* pixelValue = (byte*)bottomScanLine.ToPointer();
for (int count = 0; count < bits.Width * bits.Height; count++ )
{
pixelValue[0] = 0;
pixelValue[1] = 0;
pixelValue[2] = 0;
pixelValue = pixelValue + 4;
}
}
dest.UnlockBits(bits);
}
My question is this. Is there a problem with me marking my assembly Unsafe?
It wont be used on a website or anything, only as part of an installed
desktop application.
Thanks

Pete
Jun 27 '08 #1
0 1509

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

Similar topics

0
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...
3
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...
6
by: Cable | last post by:
Hello, I am hoping that someone can answer a question or two regarding file access. I have created an app that reads an image from a file then displays it (using OpenGL). It works well using...
1
by: Frank Rizzo | last post by:
How would I go about adding a drop shadow to a picture box? Thanks
1
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...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
16
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:...
3
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...
2
by: Peter Morris | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
0
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,...
0
jinu1996
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...
0
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...

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.