home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Sprite / c / MemSizeIcn < prev   
Encoding:
Text File  |  1993-07-11  |  1.8 KB  |  55 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Sprite.MemSizeIcn.c
  12.     Author:  Copyright © 1993 Tom Kirby-Green
  13.     Version: 1.00 (12 Jul 1993)
  14.     Purpose: Calculate the size in bytes of a sprite with the given parameters
  15.              if it were to exactly fill the given WIMP icon. Also returns
  16.              the width and height of the icon.
  17. */
  18.  
  19.  
  20. #include "DeskLib:Sprite.h"
  21. #include "DeskLib:SWI.h"
  22.  
  23.  
  24. #define XOS_ReadModeVariable 0x20035
  25.  
  26.  
  27. extern int Sprite_IconMemorySize(window_block *pWinBlock, icon_handle icon,
  28.                                  int mode, spritemem_flags flags,
  29.                                  wimp_point *dimensions)
  30. {
  31.   wimp_rect  *iconbox;
  32.   wimp_point eig, size;
  33.  
  34.   /* Extract icon's bounding box */
  35.   iconbox = &(((icon_block*)(pWinBlock+1))[icon].workarearect);
  36.  
  37.   /* Get scaling factors */
  38.   SWI(2, 3, XOS_ReadModeVariable,
  39.                 mode, 4,
  40.       /* TO */  NULL, NULL, &eig.x );
  41.  
  42.   SWI(2, 3, XOS_ReadModeVariable,
  43.                 mode, 5,
  44.       /* TO */  NULL, NULL, &eig.y );
  45.  
  46.   /* Convert OS units to pixels */
  47.   size.x  = ( iconbox->max.x - iconbox->min.x ) >> eig.x;
  48.   size.y  = ( iconbox->max.y - iconbox->min.y ) >> eig.y;
  49.  
  50.   if (dimensions != NULL)          /* If user wants size returned, return it */
  51.     *dimensions  = size;
  52.  
  53.   return(Sprite_MemorySize(size.x, size.y, mode, flags));
  54. }
  55.