realbasic-nug
[Top] [All Lists]

Re: Getting section of picture

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Getting section of picture
From: Thom McGrath <lists at thezaz dot com>
Date: Sun, 30 Dec 2007 15:37:50 -0500
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <283C6F6A-4B61-4992-B6C4-E38690FAB9FF at thezaz dot com> <3960D2BA-FE81-4529-893A-F6BCDD2C6331 at yahoo dot it>
On Dec 30, 2007, at 2:37 PM, Massimo Valle wrote:

> You can draw the source mask into the target mask, then fillrect the
> source mask with &c000000 to strip the mask and then drawpicture the
> source into the target.


Sounds like it'll work faster than pixel-by-pixel:

Protected Function Part(Source As Picture, X As Integer, Y As Integer,  
Width As Integer, Height As Integer) As Picture
   dim p as picture
   dim x1,y1 as integer

   p = newpicture(width,height,32)

   for x1 = x to x + (width - 1)
     for y1 = y to y + (height - 1)
       p.graphics.pixel(x1 - x,y1 - y) = source.graphics.pixel(x1,y1)
     next y1
   next x1

   p.mask.graphics.drawpicture source.mask, 
0,0,width,height,x,y,width,height

   return p
End Function

--
Thom McGrath
The ZAZ Studios
<http://www.thezaz.com/> AIM: thezazstudios


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>