Solved

Drop Shadow and Torn Paper Graphics Effects

Posted on 2004-09-28
10
329 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now