hard stuff... for me at least! (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Deleting in 4D65
Next thread: Is it possible...


[OT] How to compile Carbon Shared Library w/ProjectBuilder?   -   Hadley, Joshua
  hard stuff... for me at least!   -   Alexander Cohen
   Re: hard stuff... for me at least!   -   Joseph J. Strout
    Re: hard stuff... for me at least!   -   Alexander Cohen
    Re: hard stuff... for me at least!   -   Greg Ewing
   Re: hard stuff... for me at least!   -   Greg Ewing
    Re: hard stuff... for me at least!   -   Alexander Cohen
   Re: hard stuff... for me at least!   -   Søren Olin <
   Re: hard stuff... for me at least!   -   Søren Olin <

hard stuff... for me at least!
Date: 12.12.02 16:45 (Thu, 12 Dec 2002 10:45:59 -0500)
From: Alexander Cohen
I've got a picture into wich i draw in back. The black portions are
used as a mask so i can check if a click on that image is in a
clickable region. So if i click in a black portion of the image, the
click is good, and if not, well, the click is no good!

So now i'm at the point where i have a selection marquee. And i need to
know if that selection marquee is touching any part of the black
portion in my picture (the mask). I don't have the coordinates of the
balck portion in the picture, i do have the coordinates of the
selection marquee.

The only way i can think of is to check the rgbsurface of the image for
black pixels for every pixel contained in the selection marquee, but
that is overkill. It's going to sloww down my app so much. Does anyone
have any other ideas on how i could do this?

thanx,
Alex

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: hard stuff... for me at least!
Date: 12.12.02 16:56 (Thu, 12 Dec 2002 07:56:30 -0800)
From: Joseph J. Strout
At 10:45 AM -0500 12/12/02, Alexander Cohen wrote:

>So now i'm at the point where i have a selection marquee. And i need
>to know if that selection marquee is touching any part of the black
>portion in my picture (the mask). I don't have the coordinates of
>the balck portion in the picture, i do have the coordinates of the
>selection marquee.
>
>The only way i can think of is to check the rgbsurface of the image
>for black pixels for every pixel contained in the selection marquee,
>but that is overkill. It's going to sloww down my app so much. Does
>anyone have any other ideas on how i could do this?

You don't need to check the contents of the selection marquee; you
only need to check the borders. Assuming your selection is
rectangular, this just means checking 4 lines of pixels. This will
be very fast (unless you make some mistake like getting your
RGBSurface inside the loop, instead of outside). Give it a try and
if it seems slow, post the code here.

Cheers,
- Joe

Re: hard stuff... for me at least!
Date: 12.12.02 17:45 (Thu, 12 Dec 2002 11:45:37 -0500)
From: Alexander Cohen
Cool, that will make it much faster. I should be good with this, thanks!

Alex
On Thursday, December 12, 2002, at 10:56 AM, Joseph J. Strout wrote:

> At 10:45 AM -0500 12/12/02, Alexander Cohen wrote:
>
>> So now i'm at the point where i have a selection marquee. And i need
>> to know if that selection marquee is touching any part of the black
>> portion in my picture (the mask). I don't have the coordinates of the
>> balck portion in the picture, i do have the coordinates of the
>> selection marquee.
>>
>> The only way i can think of is to check the rgbsurface of the image
>> for black pixels for every pixel contained in the selection marquee,
>> but that is overkill. It's going to sloww down my app so much. Does
>> anyone have any other ideas on how i could do this?
>
> You don't need to check the contents of the selection marquee; you
> only need to check the borders. Assuming your selection is
> rectangular, this just means checking 4 lines of pixels. This will be
> very fast (unless you make some mistake like getting your RGBSurface
> inside the loop, instead of outside). Give it a try and if it seems
> slow, post the code here.
>
> Cheers,
> - Joe
>
> --
> ,------------------------------------------------------------------.
> | Joseph J. Strout REAL Software, Inc. |
> | <email address removed> http://www.realsoftware.com |
> `------------------------------------------------------------------'
>
> ---
> A searchable archive of this list is available at:
> <http://dbserver.realsoftware.com/KBDB/search.php>
> Unsubscribe:
> <mailto:<email address removed>>
> Subscribe to the digest:
> <mailto:<email address removed>>

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: hard stuff... for me at least!
Date: 12.12.02 23:49 (Fri, 13 Dec 2002 11:49:41 +1300 (NZDT))
From: Greg Ewing
"Joseph J. Strout" <<email address removed>>:

> You don't need to check the contents of the selection marquee; you
> only need to check the borders.

Provided you're only interested in things which actually
cross the border of the marquee, and not things which are
completely contained within it...

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
<email address removed> +--------------------------------------+

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: hard stuff... for me at least!
Date: 12.12.02 23:47 (Fri, 13 Dec 2002 11:47:41 +1300 (NZDT))
From: Greg Ewing
Alexander Cohen <<email address removed>>:

> So now i'm at the point where i have a selection marquee. And i need to
> know if that selection marquee is touching any part of the black
> portion in my picture (the mask).

This would be easy if RB provided access to Quickdraw's
region facilities. Then you could represent the mask
using a region and test whether it intersected another
rect or region very quickly.

This could probably be done using some Declares, but
it wouldn't be straightforward.

Or maybe there's something in the MBS plugin for this?-)

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
<email address removed> +--------------------------------------+

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: hard stuff... for me at least!
Date: 13.12.02 00:28 (Thu, 12 Dec 2002 18:28:15 -0500)
From: Alexander Cohen
It would be great if RB gave access to something that resembles a
quickdraw region. I can't use declares becuase i need a Xplat solution
and i don't think any like region exist on Win!

Alex

On Thursday, December 12, 2002, at 05:47 PM, Greg Ewing wrote:

> Alexander Cohen <<email address removed>>:
>
>> So now i'm at the point where i have a selection marquee. And i need
>> to
>> know if that selection marquee is touching any part of the black
>> portion in my picture (the mask).
>
> This would be easy if RB provided access to Quickdraw's
> region facilities. Then you could represent the mask
> using a region and test whether it intersected another
> rect or region very quickly.
>
> This could probably be done using some Declares, but
> it wouldn't be straightforward.
>
> Or maybe there's something in the MBS plugin for this?-)
>
> Greg Ewing, Computer Science Dept,
> +--------------------------------------+
> University of Canterbury, | A citizen of NewZealandCorp, a |
> Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
> <email address removed> +--------------------------------------+
>
> ---
> A searchable archive of this list is available at:
> <http://dbserver.realsoftware.com/KBDB/search.php>
> Unsubscribe:
> <mailto:<email address removed>>
> Subscribe to the digest:
> <mailto:<email address removed>>

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: hard stuff... for me at least!
Date: 12.12.02 17:03 (Thu, 12 Dec 2002 18:03:03 +0200)
From: Søren Olin <
You could maybe also make a new picture containing the mask clipped to the
selection. Scale this picture down to 1 pixel and check if the resulting
pixel is white or slightly grey.

Possible problems
you might need to check when 1 black pixel among X white would translate to
white, in which case you would need to scale down to a little more than 1
pixel. You might also need to check if this works on monitors that - no
matter depth of your image - is set to lower color depths.

Best,
Søren Olin

> So now i'm at the point where i have a selection marquee. And i need to
> know if that selection marquee is touching any part of the black
> portion in my picture (the mask). I don't have the coordinates of the
> balck portion in the picture, i do have the coordinates of the
> selection marquee.

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>

Re: hard stuff... for me at least!
Date: 13.12.02 09:41 (Fri, 13 Dec 2002 10:41:50 +0200)
From: Søren Olin <
Though my previous solution would work, it might be even better to pass the
mask as 32bit picture cropped to selection, scale it to half size place it
in a 1bit image, copy the 1 bit image back to the 32bit scale it to half
size... continue doing this until the image is 1x1 pixel - even a 640 MB rgb
image in 50x50 inches, 300 dpi would only recquire this loop to execute some
14 times, and in the end you would have a black pixel if the selected mask,
no matter size or depth, contained just a single black pixel, or a white
pixel if it contained none. Could imagine that you should make sure that
halfs should be rounded up and not just cut to integers, and naturally make
sure that you have defined your two NewPicture objects before you enter the
loop.

Best,
Søren

> You could maybe also make a new picture containing the mask clipped to the
> selection. Scale this picture down to 1 pixel and check if the resulting pixel
> is white or slightly grey.
>
> Possible problems
> you might need to check when 1 black pixel among X white would translate to
> white, in which case you would need to scale down to a little more than 1
> pixel. You might also need to check if this works on monitors that - no matter
> depth of your image - is set to lower color depths.
>
> Best,
> Søren Olin
>
>> So now i'm at the point where i have a selection marquee. And i need to
>> know if that selection marquee is touching any part of the black
>> portion in my picture (the mask). I don't have the coordinates of the
>> balck portion in the picture, i do have the coordinates of the
>> selection marquee.

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

Subscribe to the digest:
<mailto:<email address removed>>