Solved

Drop Shadow and Torn Paper Graphics Effects

Posted on 2004-09-28
10
346 Views
Last Modified: 2010-04-05
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
Comment
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
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12177162
0
 

Author Comment

by:Mutley2003
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

by:Ivanov_G
ID: 12178336
aaa, if you mean the "Drop Shadow" effect (PhotoShop like), I don't think I can help ...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:Bart_Thomas
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

by:Bart_Thomas
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

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

Expert Comment

by:Slick812
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

by:Mutley2003
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

http://www.psptips.com/4/readers/tornedge.html

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

by:Mutley2003
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

by:
Bart_Thomas earned 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question