Solved

Drop Shadow and Torn Paper Graphics Effects

Posted on 2004-09-28
10
324 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
Comment Utility
0
 

Author Comment

by:Mutley2003
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

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

Expert Comment

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

15 Experts available now in Live!

Get 1:1 Help Now