Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Oct 20, 2017 12:59 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Grab part of a loaded image
PostPosted: Tue Aug 16, 2011 12:57 am 
Offline

Joined: Wed Nov 30, 2005 8:22 pm
Posts: 227
Location: L.I., New York
I am using the DoubleBuffer property of the canvas when my program runs in Windows. Problem is, it looses its transparency which removes the background image behind it. I need to grab the portion of the background image that is being discarded and redraw it where is needs to go.

The canvas has the following properties:
Left: 256
Top: 256
Height: 256
Width: 256

The background image is 1024 x 768.

The background image is stored in variable bgpic and the variable that controls the canvas image is imgTmp(2) which is located in the Paint event of that canvas.

I had an example project that showed me what to do but I can no longer find it.

Any help is appreciated.

EDIT: I finally got it.

In the paint event of the Canvas, I used the following code:
If index = 2 and TargetWin32 then
g.DrawPicture(bgpic,0,0,256,256,256,256,256,256)
End
This way if only fires if the game is being run on Windows since Mac OS X does not require the DoubleBuffer on.


Top
 Profile  
Reply with quote  
 Post subject: Re: Grab part of a loaded image
PostPosted: Sat Jan 14, 2012 7:00 am 
Offline

Joined: Wed Nov 30, 2005 8:22 pm
Posts: 227
Location: L.I., New York
Update:

How do copy a portion of one Picture property to another?

The original picture is:

Height = 768
Width = 1024


I need to copy a small portion of this image into another picture property.

The new picture will be located at:

Left = 347
Top = 50
Width = 600
Height = 510

Any ideas?


Top
 Profile  
Reply with quote  
 Post subject: Re: Grab part of a loaded image
PostPosted: Sat Jan 14, 2012 12:22 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
g.drawpicture does everything you are asking about.

read up on it more in the LR

the main reason it needs two sets of coordinates, is to provide the ability to cut a piece from one picture and paste it into another
as well as zoom in/out at the same time

Image as Picture,
X as Integer, Y as Integer
,DestWidth as Integer, DestHeight as Integer
, SourceX as Integer, SourceY as Integer
, SourceWidth as Integer, SourceHeight as Integer

Draws the picture at the specified location. The picture can be shown at full size, cropped, or scaled. All units are pixels. X and Y are the distances from the top-left corner of the control or window from which the 0,0 point of the image will be drawn. The optional parameters are used to copy a portion of the picture (cropping) and for scaling the picture. If you are cropping, then DestWidth and DestHeight are also required. If you are doing scaling, then all of the optional parameters are required. You scale an image by making the destination width and height different from the source width and height.
The parameters SourceX, SourceY, SourceWidth, and SourceHeight describe the portion of the image that will be scaled. DestWidth and DestHeight are used to change the scaling of the picture when SourceWidth and SourceHeight are provided. SourceX and SourceY default to 0 and are used to determine the upper-left coordinate you wish to copy from.


If source X,Y,W,H are equal to Dest X,Y,W,H then it is simply a draw the picture as is
but if Dest X,Y are different... it will cut the piece as defined by source, and paste it to the coordinate defined in DEST

if the W,H value are different, then it will scale the picture based on the ratio between the two sets of values

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group