Link to home
Start Free TrialLog in
Avatar of summerset
summerset

asked on

Picture/Image Wipe - VB to Delphi??

Hello...I'm a VB Programmer in the process (early stages) of learning Delphi. Right now I am converting some old programs from VB to Delphi to get a better handle on Delphi's syntax. Please examine the following Visual basic Sub:

Sub Fade(Pic As PictureBox, Style As Integer, Blocks As Integer)

Dim width_section_size As Integer
Dim height_section_size As Integer
Dim i As Integer, j As Integer

'Corrects Blocks if needed
If Blocks < 5 Then Blocks = 5
If Blocks > 100 Then Blocks = 100

'Sets the size of each width section
width_section_size = Pic.ScaleWidth / Blocks

'Sets the size of each height section
height_section_size = Pic.ScaleHeight / Blocks

For i = 0 To Blocks
  For j = 0 To Blocks
    Pic.Line ((i * width_section_size), (j * height_section_size))-((i + 1) * width_section_size, (j + 1) * height_section_size), , BF
    DoEvents
  Next
  DoEvents
Next
   
End Sub

I have been using this in some of my programs to do a simple wipe from left to right with a pictureBox. I am now trying to do the same thing in Delphi using Image1, but quite frankly I'm having a tough time. Could someone give me a hand in converting this code? I would appreciate any help or assistance.

Thanks in advance.

-S
Avatar of Matvey
Matvey

Well, here is is:

procedure Fade(Pic: TImage; Style: Integer; Blocks: Integer);
var
  width_section_size: Integer;
  height_section_size: Integer;
  i, j: Integer;
begin
  //Corrects Blocks if needed
  If Blocks < 5 Then Blocks := 5;
  If Blocks > 100 Then Blocks := 100;

  //Sets the size of each width section
  width_section_size := Pic.{Scale}Width div Blocks;

  //Sets the size of each height section
  height_section_size := Pic.{Scale}Height div Blocks;

  for i := 0 to Blocks do begin
    for j := 0 To Blocks do begin
      Pic.Canvas.MoveTo(i*width_section_size, j*height_section_size);
      Pic.Canvas.LineTo((i+1)*width_section_size, (j+1)*height_section_size);
      Application.ProcessMessages;
    end;
    Application.ProcessMessages;
  end;
end;

I didn't post this as an answere becuase I'm not sure what for is this code and what it's supse to be doing. When I execute it it dithers the image very very sloooowllly. I don't have VB here now, so I can't test your code either.
Can you exaplin better what for to write such code ti wipe an image?
The Style parameter isn't used... (???)
If you'ra new no one may have told you that you can find a lot of components for
delphi.
Fading components exist and work very well.
Go to www.torry.ru and look around in the vcl/graphics-multimedia section
You may find some of them there.
Fading component? Is that what you're trying to make? If so, just two days ago I made such component - gradient (fading if you want). If you want to see it then you can download it at: http://www.delphipages.com/edit/count.cfm?comID=447&Link=uploads%2FGraphics%2FVIGrdnt%2Ezip


                                SURFACE FILL GRADIENT
                                CONTROL
                                •Fast drawing
                                •Non-Flickering
                                Written with just a few lines of code

Avatar of summerset

ASKER

Thanks, you're right it is very slow. To answer some of your questions...it's part of a function that does various types of transitions. Wipe left to right, top to bottom, etc. The style parameter would specify which type of wipe if they were all in a case select statement. The part I posted was just left to right. If you'd like the VB .bas file, let me know where to send it.

Thanks for the pointer to the gradient fill -- that is very cool!! But, what I am trying to do is just do a screen wipe from left to right. I have Image1 on a form and I want to wipe to black.

I realize there are a couple of freeware components availabele that do screen transitions like fade, etc., but honestly...as neat as HARMFADE.PAS is...it really doesn't display the images well. The price is right though. :-)

Matvey, you did answer my question, so if you post it again as an answer, I'll give you the points. The example you showed me has helped me understand more about writing my own procedures in Delphi.

Also, if you have any other examples concerning Wipe, Random Pixel Fade, etc. please let me know.

Thanks again!!

Sincerely,

-S
ASKER CERTIFIED SOLUTION
Avatar of Matvey
Matvey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
http://bes.trendline.co.il/torry/vcl/graphics/fximg11.zip
"These two components derived from TGraphicComponent encapsulate the TImage and TLabel characteristics along with special effects during painting. Absolutely necessary for Multimedia developers and those who want to improve their applications' splash screens."

http://bes.trendline.co.il/torry/vcl/graphics/tfx.zip
"An image-component with various FX effects."

http://bes.trendline.co.il/torry/vcl/graphics/ffpbox.zip
"A simple replacement of TPaintBox which provide flickerless redrawing. Very useful when you need to draw complex image with animation effects."

http://bes.trendline.co.il/torry/vcl/graphics/pixelshw.zip
"TPixelShow is a visual component that will show your pictures appearing from pixels."(!!!)

What do you think?