Link to home
Start Free TrialLog in
Avatar of God_Ares
God_Ares

asked on

Need a HIGH preform graphics

I want to show a TBitmap, that is being modified very often, to an user (20+ frames a second). If possible in a form (600x400). I need delphi 3 example with source.
Avatar of jack_p50
jack_p50

See here in VCL section in graphics part - here are many such things as you need :
http://bes.trendline.co.il/torry/
Hmmm.. Hey Jack! I don't see any source ?

God_Ares: here's a way to deal with it:

You need to drop a TOpenPictureDialog to your form and then add a Form OnCreate event procedure, the n the rest is cut'n'paste:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtDlgs, ExtCtrls;

type
  TForm1 = class(TForm)
    OpenPictureDialog1: TOpenPictureDialog;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    a,b: TBitmap;
    Timer: TTimer;
    Next: Integer;
    Function GetNewImage: TBitmap;
    procedure OnTime(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

Function TForm1.GetNewImage: TBitmap;
begin
  Result:= TBitmap.Create;
  If OpenPictureDialog1.Execute then
    Result.LoadFromFile(OpenPictureDialog1.Filename);
End;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ClientWidth:= 640;
  ClientHeight:= 480;
  a:= GetNewImage;
  b:= GetNewImage;
  Next:= 0;
  Timer:= TTimer.Create(Self);
  Timer.Interval:= 1000;
  Timer.OnTimer:= OnTime;
  Timer.Enabled:= True;
end;

procedure TForm1.OnTime(Sender: TObject);
var
  TempHandle: hWnd;
  dwRop: DWord;
begin
  next:= 1-Next;
  dwRop:= SRCCOPY;
  If next=0 then TempHandle:= a.Canvas.Handle else TempHandle:= b.Canvas.Handle;
  BitBlt(
    Canvas.Handle,      // handle to destination device context
    0,                  // x-coordinate of destination rectangle's upper-left corner
    0,                  // y-coordinate of destination rectangle's upper-left corner
    640,            // width of destination rectangle
    480,            // height of destination rectangle
    TempHandle,            // handle to source device context
    0,                  // x-coordinate of source rectangle's upper-left corner
    0,                  // y-coordinate of source rectangle's upper-left corner
    dwRop             // raster operation code (See below)
   );
{
BLACKNESS      Fills the destination rectangle using the color associated with
            index 0 in the physical palette. (This color is black for the
                default physical palette.)
DSTINVERT      Inverts the destination rectangle.
MERGECOPY      Merges the colors of the source rectangle with the specified
            pattern by using the Boolean AND operator.
MERGEPAINT      Merges the colors of the inverted source rectangle with the
            colors of the destination rectangle by using the Boolean OR
                operator.
NOTSRCCOPY      Copies the inverted source rectangle to the destination.
NOTSRCERASE      Combines the colors of the source and destination rectangles
            by using the Boolean OR operator and then inverts the resultant
                color.
PATCOPY            Copies the specified pattern into the destination bitmap.
PATINVERT      Combines the colors of the specified pattern with the colors of
            the destination rectangle by using the Boolean XOR operator.
PATPAINT      Combines the colors of the pattern with the colors of the
            inverted source rectangle by using the Boolean OR operator. The
                result of this operation is combined with the colors of the
                destination rectangle by using the Boolean OR operator.
SRCAND            Combines the colors of the source and destination rectangles
            by using the Boolean AND operator.
SRCCOPY            Copies the source rectangle directly to the destination
            rectangle.
SRCERASE      Combines the inverted colors of the destination rectangle with
            the colors of the source rectangle by using the Boolean AND operator.
SRCINVERT      Combines the colors of the source and destination rectangles
            by using the Boolean XOR operator.
SRCPAINT      Combines the colors of the source and destination rectangles by
            using the Boolean OR operator.
WHITENESS      Fills the destination rectangle using the color associated with
            index 1 in the physical palette. (This color is white for the
                default physical palette.)
}
End;
end.

..You should maybe said the timer to 50, and you will see.

Cheers,
Williams
Avatar of God_Ares

ASKER

Sorry jack_p50,

I agree with williams2. It isn't exactly as i wanted to be...

But Williams2 answer was perfect. So i must be honest and give points to williams2.

Please williams2 answer this question (with a dummy answer)
and recieve those points!.

Thanx to all...
Greetz God_Ares.
See Graphics examples on   http://www.efg2.com/lab/
Try direct-x components.
ASKER CERTIFIED SOLUTION
Avatar of williams2
williams2

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