Solved

Drop Shadow and Torn Paper Graphics Effects

Posted on 2004-09-28
10
341 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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