"Chrissy R" <[EMAIL PROTECTED]> wrote on 9/02/2001 01:05:03:
<snip>
>> Something like:
>
>You may be correct - BUT - I don't understand that code.  What is
>fastcall?  What is the "::"?  What is "*" before "Sender"?  What is
>"->".  This does  not look like the Delphi code I write.

Sorry, it was Borland C++ Builder code.  I just copied it from an old 
project of mine.  I've just had it pointed out to me that I should 
really present code examples in Delphi OP, so here goes: 

procedure TViewForm.ViewPanelResize(Sender: TObject);
begin
  framebuffer.Width := Image1.Width;
  framebuffer.Height := Image1.Height;
  Image1.Picture.Assign(framebuffer);
end;

>> This forces the bitmap that the TImage's picture is stored in to be
>> properly resized when the form size changes, which should fix the
>> problem with not being able to draw to the whole image.
>
>That makes sense.  It appears that a TImage needs an image to be
>in it.

When the TImage is created the TImage.Picture member is correctly 
initialised with a TPicture of the correct dimensions to store the 
actual image information in.  Unfortunately when you resize the TImage 
it doesn't automatically resize the TPicture, so if you make the TImage 
larger you get blank bits where the Picture isn't big enough.  By 
assigning a larger TBitmap to the Picture you force it to the correct 
dimensions. 

>> Can't say I've tried to use a TImage that size.  However a 
>> 2048x2048x24 image is going to take up something like 12meg of ram, 
>> which is a little expensive.  If you really need to support images 
>> this size I'd suggest trying something a little less memory hungry, 
>> even if it means a relatively large amount of time spent drawing.
>
>I cannot have it slow to draw.  I need fast redrawing and efficient
>programming.  Students will be working on this code so it has to be
>simple and not at all convoluted AND it has to be fast and flicker free
>in the drawing.

If you draw to a TBitmap and then copy it to the TImage using Image.
Canvas.CopyRect(), then there is no flicker that I can detect.  The 
image isn't cleared before the bitmap is copied.  As for the memory... 
if you set the TBitmap.PixelFormat to pf8bit you'll get a 256-color 
bitmap which will be 1/3rd as large as an equivalent 24-bit bitmap.  
It's also faster to draw to than 24bit, although very slightly slower 
when copying to the screen. 

If redrawing every time the scrollbars move is too slow, how about 
using the same method but maintaining a complete copy of the image in a 
TBitmap?  Then you select the appropriate section to copy into the 
smaller TImage.  Let me see if I can express this in OP: 

procedure TViewForm.UpdateImage;
var
  sRect, dRect: TRect;
  x, y: Integer;
begin
  x = HScrollBar.Position;
  y = VScrollBar.Position;
  dRect := Image1.Canvas.ClipRect;
  sRect := dRect;
  Inc(sRect.Left,x);
  Inc(sRect.Right,x);
  Inc(sRect.Top,y);
  Inc(sRect.Bottom,y);

  Image1.Canvas.CopyRect(dRect, backbuffer.Canvas, sRect);
end;

Did that make any sense?  I'm not really comfortable writing OP :>

Basically what I'm trying to achieve is to copy a rectangle the same 
size as the TImage from a selected position in a larger TBitmap. 


>Is there a component that is a line?  I want a line that can go on any 
>angle and that I can select and pickup and move.

Not a standard one, although there may be a third-party one floating 
around somewhere. 

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to