Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Drop Shadow and Torn Paper Graphics Effects

Posted on 2004-09-28
Medium Priority
354 Views
I have been looking around for Delphi code or algorithms for these effects and I have not been able to find a source.

Can anyone help me .. rough out some code perhaps?

Thanks
0
Question by:Mutley2003
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 3
• 2
• +1

LVL 12

Expert Comment

ID: 12177162
0

Author Comment

ID: 12177879
I guess I was not clear enough in my request. Ivanov G's solution applies to windows.

I want these graphicFX to apply to an image (Timage, TBitmap etc)

0

LVL 12

Expert Comment

ID: 12178336
aaa, if you mean the "Drop Shadow" effect (PhotoShop like), I don't think I can help ...
0

LVL 1

Expert Comment

ID: 12181813
Dropshadow could be done by drawing a (usually) black rectangle and then applying a "blurfilter".
The filter replaces the "color" of a pixel witht the average of it's neighbours (and itself).
0

LVL 1

Expert Comment

ID: 12182704
This kinda looks like torn paper. You could use this as a mask.

procedure TForm1.Button2Click(Sender: TObject);

procedure fractal (B: TBitmap; t1,f1,t2,f2, resolution,roughness: double);
var
r,tmid,fmid: double;
begin
if (sqr(t2 - t1) + sqr(f2 - f1)) < sqr(resolution) then
begin
B.Canvas.MoveTo(round(t1), round(f1));
B.Canvas.LineTo(round(t2), round(f2));
end
else begin
r := 2 * random - 1;
tmid := (t1 + t2) / 2 - roughness * (f2 - f1)*r;
fmid := (f1 + f2) / 2 + roughness * (t2 - t1)*r;

fractal (B, t1,f1, tmid,fmid, resolution,roughness);
fractal (B, tmid,fmid, t2,f2, resolution,roughness);
end;
end;

var
B: TBitmap;
y1,y2: Integer;
begin
B := TBitmap.Create;
try
B.Width := 400;
B.Height := 400;
B.PixelFormat := pf8Bit;
B.canvas.Brush.Color := clWhite;
B.Canvas.FillRect(RECT(0,0,B.Width,B.Height));

y1 := Trunc (200 * (1 + Random));
y2 := Trunc (200 * (1 + Random));

fractal (B, 0,y1, B.Width,y2, 4, 0.2);

B.canvas.Brush.Color := clBlack;
B.canvas.FloodFill(2,2, clBlack, fsBorder);

BitBlt (Canvas.Handle, 0,0,B.Width,B.Height, B.Canvas.Handle, 0,0, SRCCOPY);
finally
B.Free;
end;
0

LVL 1

Expert Comment

ID: 12182712
Ow.. it's from 3D Computer Graphics by Alan Watt (2nd edition)
0

LVL 34

Expert Comment

ID: 12186012
hello Mutley2003 , can you give some more info about your "Drop Shadow", do you just want a rectangular drop shadow (darken blend to an existing bitmap)  ? ? Or maybe some "How does it look" about the Torn Paper Graphics Effects?
0

Author Comment

ID: 12186634
Bart, is "3D Computer Graphics by Alan Watt" in Pascal ? still in print?

Slick812 .. no, not just rectangular.

This example combines the two effects

This is not so clear
http://www.iboost.com/build/software/psp/939.htm

also called "ripped edges"
http://www.cbtcafe.com/fireworks/rippededges/rippededges.html

0

Author Comment

ID: 12186675
also some nice "torn paper" effects here
http://www.ec-software.com/tnt3.htm

Apparently you can do a "ragged edge" with the GIMP by using distress in script-fu.
http://lists.xcf.berkeley.edu/lists/gimp-user/1999-September/000003.html
Source for that would possibly be available deep in the GIMP (in C, though)

0

LVL 1

Accepted Solution

Bart_Thomas earned 2000 total points
ID: 12188743
> Bart, is "3D Computer Graphics by Alan Watt" in Pascal ? still in print?

I don't think it is. I have another, newer book, which is in C.

My guess is, the fractal-line can produce the desired torn effect. The mask can be used to split the image in two. The maskcan also be used to create the dropshadow. Just apply a uniform 3x3 averaging filtering (example: http://www.incx.nec.co.jp/imap-vision/library/wouter/avef3uni.html).
If you repeat that process several times, you get a dropshadow-like effect. The resulting bitmap can be pasted (alpha-blended if you have a background). The torn image can be pasted over the shadow.

I'm not that familiar with GIMP, but it might provide some clues in what filters or techniques are used to create the effect desired.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code Â  (CODE) The Imâ€¦
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usuaâ€¦
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a qâ€¦
###### Suggested Courses
Course of the Month11 days, 18 hours left to enroll