Solved

Picture/Image Wipe - VB to Delphi??

Posted on 1998-07-20
7
365 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:summerset
  • 5
7 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1358265
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?
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1358266
The Style parameter isn't used... (???)
0
 
LVL 4

Expert Comment

by:jeurk
ID: 1358267
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.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Expert Comment

by:Matvey
ID: 1358268
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

0
 

Author Comment

by:summerset
ID: 1358269
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
0
 
LVL 3

Accepted Solution

by:
Matvey earned 150 total points
ID: 1358270
Hi, I've found some intersting stuff:

http://bes.trendline.co.il/torry/vcl/graphics/harmfade.zip
"HarmFade is an animation effect. It will transition from one bitmap to another, using "Dissolve" or "Blend"."

http://bes.trendline.co.il/torry/vcl/graphics/wiatile.zip
"Tiles bitmaps images - either simple tiling, transparent tiling or faded tiling"

Hope this is interesting.
--Matvey
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1358271
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?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 253
Convert Jpg /PNG To GIF 5 103
Delphi inherited method 6 42
Delphi...Split view - idea? 1 0
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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