Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
problem with TImage canvas Posted by GarryPaxton on 15 Nov 2004 at 3:27 AM
This message was edited by GarryPaxton at 2004-11-15 3:33:43

This message was edited by GarryPaxton at 2004-11-15 3:28:39

I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.

However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.

The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).

Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?

many thanks





Report
Re: problem with TImage canvas Posted by zibadian on 15 Nov 2004 at 3:53 AM
: This message was edited by GarryPaxton at 2004-11-15 3:33:43

: This message was edited by GarryPaxton at 2004-11-15 3:28:39

: I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
:
: However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
:
: The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
:
: Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
:
: many thanks
:
:
You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
Report
Re: problem with TImage canvas Posted by GarryPaxton on 15 Nov 2004 at 4:26 AM
: : This message was edited by GarryPaxton at 2004-11-15 3:33:43

: : This message was edited by GarryPaxton at 2004-11-15 3:28:39

: : I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
: :
: : However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
: :
: : The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
: :
: : Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
: :
: : many thanks
: :
: :
: You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
: If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
:
Thanks, I will investigate TPaintbox. However, I do need to load bitmaps so I might be compelled to use TImage.

I do resize TImage before loading the next picture (Img1.width and height properties), and although the Timage does indeed incresse in size, the usable canvas within it just stays the same.
Report
Re: problem with TImage canvas Posted by zibadian on 15 Nov 2004 at 6:00 AM
This message was edited by zibadian at 2004-11-15 6:2:46

: : : This message was edited by GarryPaxton at 2004-11-15 3:33:43

: : : This message was edited by GarryPaxton at 2004-11-15 3:28:39

: : : I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
: : :
: : : However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
: : :
: : : The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
: : :
: : : Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
: : :
: : : many thanks
: : :
: : :
: : You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
: : If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
: :
: Thanks, I will investigate TPaintbox. However, I do need to load bitmaps so I might be compelled to use TImage.
:
: I do resize TImage before loading the next picture (Img1.width and height properties), and although the Timage does indeed incresse in size, the usable canvas within it just stays the same.
:
The Canvas itself doesn't have a real size. It should be the same size as the picture, which has been loaded. So if you first edit a 100x100 bitmap, and subsequently load a 200x200 bitmap, the canvas should also be 200x200.


Report
Re: problem with TImage canvas Posted by GarryPaxton on 15 Nov 2004 at 6:19 AM
: This message was edited by zibadian at 2004-11-15 6:2:46

: : : : This message was edited by GarryPaxton at 2004-11-15 3:33:43

: : : : This message was edited by GarryPaxton at 2004-11-15 3:28:39

: : : : I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
: : : :
: : : : However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
: : : :
: : : : The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
: : : :
: : : : Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
: : : :
: : : : many thanks
: : : :
: : : :
: : : You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
: : : If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
: : :
: : Thanks, I will investigate TPaintbox. However, I do need to load bitmaps so I might be compelled to use TImage.
: :
: : I do resize TImage before loading the next picture (Img1.width and height properties), and although the Timage does indeed incresse in size, the usable canvas within it just stays the same.
: :
: The Canvas itself doesn't have a real size. It should be the same size as the picture, which has been loaded. So if you first edit a 100x100 bitmap, and subsequently load a 200x200 bitmap, the canvas should also be 200x200.
:
:

Hello, here is an example - drop a TImage on a form and manually set its dimensions to a height of 50, and a width of 50.

Then try the following code (I placed this in a Button1 Click event)
Image1.canvas.brush.color:=clBlue;
Image1.width:=1047;
Image1.Height:=1047;
Image1.canvas.fillrect(Rect(0,0,1047,1047));


For me, all I see is a 50 x 50 blue square. It never changes size, no matter what dimensions I give it.
Many thanks.
Report
Re: problem with TImage canvas Posted by zibadian on 15 Nov 2004 at 7:51 AM
: : This message was edited by zibadian at 2004-11-15 6:2:46

: : : : : This message was edited by GarryPaxton at 2004-11-15 3:33:43

: : : : : This message was edited by GarryPaxton at 2004-11-15 3:28:39

: : : : : I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
: : : : :
: : : : : However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
: : : : :
: : : : : The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
: : : : :
: : : : : Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
: : : : :
: : : : : many thanks
: : : : :
: : : : :
: : : : You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
: : : : If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
: : : :
: : : Thanks, I will investigate TPaintbox. However, I do need to load bitmaps so I might be compelled to use TImage.
: : :
: : : I do resize TImage before loading the next picture (Img1.width and height properties), and although the Timage does indeed incresse in size, the usable canvas within it just stays the same.
: : :
: : The Canvas itself doesn't have a real size. It should be the same size as the picture, which has been loaded. So if you first edit a 100x100 bitmap, and subsequently load a 200x200 bitmap, the canvas should also be 200x200.
: :
: :
:
: Hello, here is an example - drop a TImage on a form and manually set its dimensions to a height of 50, and a width of 50.
:
: Then try the following code (I placed this in a Button1 Click event)
:
: Image1.canvas.brush.color:=clBlue;
: Image1.width:=1047;
: Image1.Height:=1047;
: Image1.canvas.fillrect(Rect(0,0,1047,1047));
: 

:
: For me, all I see is a 50 x 50 blue square. It never changes size, no matter what dimensions I give it.
: Many thanks.
:
I have no idea why, but it works if you first set the Width and Height, then the Brush and then fill the rect; like this:
  Image1.width:=1047;
  Image1.Height:=1047;
  Image1.canvas.brush.color:=clBlue;
  Image1.canvas.fillrect(Rect(0,0,1047,1047));

Report
Re: problem with TImage canvas Posted by softman on 15 Nov 2004 at 1:09 PM
: : : This message was edited by zibadian at 2004-11-15 6:2:46

: : : : : : This message was edited by GarryPaxton at 2004-11-15 3:33:43

: : : : : : This message was edited by GarryPaxton at 2004-11-15 3:28:39

: : : : : : I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
: : : : : :
: : : : : : However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
: : : : : :
: : : : : : The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
: : : : : :
: : : : : : Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
: : : : : :
: : : : : : many thanks
: : : : : :
: : : : : :
: : : : : You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
: : : : : If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
: : : : :
: : : : Thanks, I will investigate TPaintbox. However, I do need to load bitmaps so I might be compelled to use TImage.
: : : :
: : : : I do resize TImage before loading the next picture (Img1.width and height properties), and although the Timage does indeed incresse in size, the usable canvas within it just stays the same.
: : : :
: : : The Canvas itself doesn't have a real size. It should be the same size as the picture, which has been loaded. So if you first edit a 100x100 bitmap, and subsequently load a 200x200 bitmap, the canvas should also be 200x200.
: : :
: : :
: :
: : Hello, here is an example - drop a TImage on a form and manually set its dimensions to a height of 50, and a width of 50.
: :
: : Then try the following code (I placed this in a Button1 Click event)
: :
: : Image1.canvas.brush.color:=clBlue;
: : Image1.width:=1047;
: : Image1.Height:=1047;
: : Image1.canvas.fillrect(Rect(0,0,1047,1047));
: : 

: :
: : For me, all I see is a 50 x 50 blue square. It never changes size, no matter what dimensions I give it.
: : Many thanks.
: :
: I have no idea why, but it works if you first set the Width and Height, then the Brush and then fill the rect; like this:
:
:   Image1.width:=1047;
:   Image1.Height:=1047;
:   Image1.canvas.brush.color:=clBlue;
:   Image1.canvas.fillrect(Rect(0,0,1047,1047));
: 

:
Hi!

When TImage is created, the picture is nil. When you first invoke any canvas function, a picture.bitmap is created with the size of the TImage itself, where TImage will paint. If you resize the image, the bitmap will stay the same, unless you resize it programmatically:

 Image1.canvas.brush.color:=clBlue;
 Image1.Picture.Bitmap.Width := 1047;
 Image1.Picture.Bitmap.Height := 1047;
 Image1.width:=1047;
 Image1.Height:=1047;
 Image1.canvas.fillrect(Rect(0,0,1047,1047));

\\///
/O O\
| | |
| _ |
\___/
SoftMan

Report
Re: problem with TImage canvas Posted by GarryPaxton on 16 Nov 2004 at 5:28 AM
: : : : This message was edited by zibadian at 2004-11-15 6:2:46

: : : : : : : This message was edited by GarryPaxton at 2004-11-15 3:33:43

: : : : : : : This message was edited by GarryPaxton at 2004-11-15 3:28:39

: : : : : : : I have a TImage canvas onto which I draw a picture, using a variety of methods (loading a bitmap, flooding an drawing lines , etc). This is in Delphi 6.
: : : : : : :
: : : : : : : However, the pictures I create can be various sizes, but the canvas seems always to be cropped at the original size it had at design time. So, if I drop a TImage on the form of 100 x 100, and then try to fillrect at some larger size, like 200 x 200, the resulting image remains cropped to 100 x 100.
: : : : : : :
: : : : : : : The only way I can get round this is to set the TImage to be sized at design time to the largest possible picture size I ever intend to create. Unfortunately, if the TImage is larger than the desktop that causes a program interrupt (unless I make it Visible:=false, which kind of defeats the object).
: : : : : : :
: : : : : : : Is there something I am doing wrong ? Does TImage need to be "initialsed" prior to use, or somehow "invalidated" to allow it to be resized ?
: : : : : : :
: : : : : : : many thanks
: : : : : : :
: : : : : : :
: : : : : : You can set the Width and Height of any control in code. Also the TImage supports stretching of images. You don't need to invalidate the control to resize it, Delphi takes care of this. You do however create a picture in it to directly write to the canvas.
: : : : : : If you only want to directly write (and not load any image files) to the canvas you can better the TPaintBox. That control has its own canvas and doesn't need an image to be loaded into.
: : : : : :
: : : : : Thanks, I will investigate TPaintbox. However, I do need to load bitmaps so I might be compelled to use TImage.
: : : : :
: : : : : I do resize TImage before loading the next picture (Img1.width and height properties), and although the Timage does indeed incresse in size, the usable canvas within it just stays the same.
: : : : :
: : : : The Canvas itself doesn't have a real size. It should be the same size as the picture, which has been loaded. So if you first edit a 100x100 bitmap, and subsequently load a 200x200 bitmap, the canvas should also be 200x200.
: : : :
: : : :
: : :
: : : Hello, here is an example - drop a TImage on a form and manually set its dimensions to a height of 50, and a width of 50.
: : :
: : : Then try the following code (I placed this in a Button1 Click event)
: : :
: : : Image1.canvas.brush.color:=clBlue;
: : : Image1.width:=1047;
: : : Image1.Height:=1047;
: : : Image1.canvas.fillrect(Rect(0,0,1047,1047));
: : : 

: : :
: : : For me, all I see is a 50 x 50 blue square. It never changes size, no matter what dimensions I give it.
: : : Many thanks.
: : :
: : I have no idea why, but it works if you first set the Width and Height, then the Brush and then fill the rect; like this:
: :
: :   Image1.width:=1047;
: :   Image1.Height:=1047;
: :   Image1.canvas.brush.color:=clBlue;
: :   Image1.canvas.fillrect(Rect(0,0,1047,1047));
: : 

: :
: Hi!
:
: When TImage is created, the picture is nil. When you first invoke any canvas function, a picture.bitmap is created with the size of the TImage itself, where TImage will paint. If you resize the image, the bitmap will stay the same, unless you resize it programmatically:
:
:
:  Image1.canvas.brush.color:=clBlue;
:  Image1.Picture.Bitmap.Width := 1047;
:  Image1.Picture.Bitmap.Height := 1047;
:  Image1.width:=1047;
:  Image1.Height:=1047;
:  Image1.canvas.fillrect(Rect(0,0,1047,1047));
: 

: \\///
: /O O\
: | | |
: | _ |
: \___/
: SoftMan
:
:
Hey that's fantastic - problem solved.
many thanks
Garry



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.