[futurebasic] Re: PICT

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1998 : Group Archive : Group : All Groups

From: exile71@... (Forrest Blanton)
Date: Tue, 23 Jun 1998 19:57:24 -0700
Rick said:
>In the case of a file, you could open it and then just read the 8 bytes
>from it which specify the frame rectangle.  That shouldn't be too bad.
>In the case of a resource, however, most Resource Manager routines are
>set up to read only the _entire_ resource, and not just a specified
>subset of it.  There _are_ ways to read a partial resource, but I've
>never tried them.

I say:
Here let me take a try at this one. I was in a good mood today so decided
it wouldn't be that hard to right up a routine that returned the hight and
width of a PICT resource. Here is the function:

'=============================================================================
CLEAR LOCAL
DIM rsrcHndl&, resErr%, h%, w%, rect.8
LOCAL FN pictRsrcRect(resID%, @pictHght&, @pictWdth&)
  CALL SETRESLOAD(_false)
  rsrcHndl& = FN GETRESOURCE(_"PICT",resID%)
  resErr% = FN RESERROR
  CALL SETRESLOAD(_pTrue)
  LONG IF resErr% = _noErr
    CALL READPARTIALRESOURCE(rsrcHndl&, 2, @rect, 8)
    resErr% = FN RESERROR
    LONG IF resErr%
      BEEP
    XELSE
      h% = rect.bottom% - rect.top%
      w% = rect.right% - rect.left%
      POKE WORD pictWdth&, w%
      POKE WORD pictHght&, h%
    END IF
  XELSE
    BEEP
  END IF
END FN
'=============================================================================

You would call it like this:

        FN pictRsrcHW(resID%, hght%, wdth%)

resID% is the ID to a PICT resource, it's assumed that the resource is an a
resource file that is already open, ie the main resource file specified
with the RESOURCE statement

hght% is the variable where the height of the picture will be returned

wdth% is the variable where the width of the picture will be returned

So if you wrote this:

        FN pictRsrcHW(128, hght%, wdth%)
        PRINT hght%, wdth%

the height and width of picture 128 would be printed.

If you would like me to write a similar function for getting the height and
width of a PICT file, I would be very willing to do so.

I will also post this to the web ring when I get around to it.

Hope this works.

Forrest Blanton


*************************************************************
*                        --Friends--                        *
*                                                           *
*               Had we never met,                           *
*               I would've just longed for her.             *
*               But now that we have,                       *
*               I couldn't live without her.                *
*                                                           *
*                               -Tonami                     *
*************************************************************