home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 600-699 / ff634.lha / APIG / apig33.lzh / bitmapscaleiff.rexx < prev    next >
OS/2 REXX Batch file  |  1992-03-08  |  4KB  |  156 lines

  1.  
  2. /* Example of loading iff pic into custom screen */
  3. /* and then Scaling the BitMap */
  4.  
  5.  x = addlib("apig.library",0,-30,0)
  6.  
  7.  call set_apig_globals()
  8.  
  9.  scr = 0 
  10.  
  11.  picture    = loadiff("gorilla")
  12.  if picture = '0000 0000'x then
  13.     do
  14.        say "I could not find picture 'GORILLA' "
  15.     end
  16.  else
  17.     do
  18.         picdispID = '00011000'x    /* LOWRES */
  19.         call showpic()
  20.     end
  21.  
  22.  
  23.  picture    = loadiff("almaden")
  24.  if picture = '0000 0000'x then
  25.     do
  26.        say "I could not find picture 'ALMADEN' "
  27.     end
  28.  else
  29.     do
  30.         picdispID = '00011800'x    /* LOWRES HAM */
  31.         call showpic()
  32.     end
  33.  
  34.  
  35.  picture    = loadiff("robotarm")
  36.  if picture = '0000 0000'x then
  37.     do
  38.        say "I could not find picture 'ROBOTARM' "
  39.     end
  40.  else
  41.     do
  42.         picdispID = '00019004'x     /* HIRES LACE */
  43.         call showpic()
  44.     end
  45.  
  46.  
  47. exit
  48.  
  49.  
  50. /* ------------------------------------------------------------ */
  51.  
  52. showpic:
  53.  
  54.  width    = iffwidth(picture)
  55.  height   = iffheight(picture)
  56.  depth    = iffdepth(picture)
  57.  viewmode = iffviewmode(picture)
  58.  ncolors  = iffcolors(picture)
  59.  colors   = iffcolortab(picture)
  60.  
  61.  say "Width     = " width
  62.  say "Depth     = " depth 
  63.  say "Height    = " height 
  64.  say "Viewmode  = " viewmode
  65.  say "Numcolors = " ncolors
  66.  say "ColorTab  = " d2x(c2d(colors))
  67.  
  68. scrtaglist = makescrtaglist()  /* build tag list for screen */
  69.  
  70. /*  scr   = openscreen(0,0,width,height,depth,1,0,viemode,CUSTOMSCREEN,0) */
  71.  
  72.  scr  = OPENSCREENTAGLIST(null(),scrtaglist)
  73.  scrrp = getscreenrastport(scr) 
  74.  
  75.  z     = useiffcolor(picture,scr) 
  76.  
  77.  /* the following blit copies the IFF image into the screens rastport */
  78.  z     = bltbitmaprastport(picture,0,0,scrrp,0,0,width,height,c2d('00c0'x)) 
  79.  
  80.  /* if you wanna save it */
  81.  /* x = saveiff(picture,"ram:newpic",colors,viewmode,1)  */
  82.  /* x = saveiff(picture,"ram:newpic",colors,viewmode,0)  */
  83.  
  84.  wait 2 sec
  85.  
  86.  bmwidth  = width / 2
  87.  bmheight = height / 2
  88.  
  89.  scalewidth  = width / 2
  90.  scaleheight = height / 2
  91.  
  92.  mybitmap = makebitmap(bmwidth,bmheight,depth)
  93.  
  94.  bms = ALLOCVEC(48,MEMF_CLEAR)            /* BitMapScaleArgs structure */
  95.                                           /* you have to hard code it  */
  96.  
  97.  call SETVALUE(bms,0,2,'n',0)             /* src X              */
  98.  call SETVALUE(bms,2,2,'n',0)             /* src Y              */
  99.  call SETVALUE(bms,4,2,'n',width)         /* src width          */
  100.  call SETVALUE(bms,6,2,'n',height)        /* src height         */
  101.  call SETVALUE(bms,8,2,'n',width)         /* Xfactor            */
  102.  call SETVALUE(bms,10,2,'n',height)       /* Yfactor            */
  103.  call SETVALUE(bms,12,2,'n',0)            /* dest X             */
  104.  call SETVALUE(bms,14,2,'n',0)            /* dest Y             */
  105.  call SETVALUE(bms,16,2,'n',bmwidth)      /* dest width         */
  106.  call SETVALUE(bms,18,2,'n',bmheight)     /* dest height        */
  107.  call SETVALUE(bms,20,2,'n',scalewidth)   /* Xfactor            */
  108.  call SETVALUE(bms,22,2,'n',scaleheight)  /* Yfactor            */
  109.  call SETVALUE(bms,24,4,'p',picture)      /* source bitmap      */
  110.  call SETVALUE(bms,28,4,'p',mybitmap)     /* destination bitmap */
  111.  
  112.  /* scale it into mybitmap */
  113.  call BITMAPSCALE(bms)
  114.  
  115.  /* blit mybitmap into screen */
  116.  z = bltbitmaprastport(mybitmap,0,0,scrrp,0,0,bmwidth,bmheight,c2d('00c0'x)) 
  117.  
  118.  wait 4 sec
  119.  
  120.  call FREEBITMAP(picture)
  121.  call FREEBITMAP(mybitmap)
  122.  call FREEVEC(bms)
  123.  
  124.  call freetagitems(scrtaglist)
  125.  
  126.  x = closescreen(scr)
  127.  
  128.  return 1
  129.  
  130.  
  131. /* ------------------------------------------------------------ */
  132.  
  133. makescrtaglist:
  134.  
  135.    scrtagl = ALLOCATETAGITEMS(18)
  136.  
  137.    sapens  = MAKEPOINTER(scrtagl,0,24,MEMF_CLEAR)
  138.  
  139.    call SETVALUE(sapens,0,2,'n',-1)
  140.  
  141.    scrpname = MAKEPOINTER(scrtagl,0,80,MEMF_CLEAR)
  142.    call export(scrpname,"MY SCREEN ONE ")
  143.  
  144.    call SETTAGSLOT(scrtagl,0,SA_Title,'p',scrpname)   
  145.    call SETTAGSLOT(scrtagl,1,SA_Left,'n',0)
  146.    call SETTAGSLOT(scrtagl,2,SA_Top,'n',0)
  147.    call SETTAGSLOT(scrtagl,3,SA_Width,'n',width)
  148.    call SETTAGSLOT(scrtagl,4,SA_Height,'n',height)
  149.    call SETTAGSLOT(scrtagl,5,SA_DISPLAYID,'p',picdispID)  /* picdispID set above */
  150.    call SETTAGSLOT(scrtagl,6,SA_Depth,'n',depth) 
  151.    call SETTAGSLOT(scrtagl,7,SA_Type,'n',CUSTOMSCREEN) 
  152.    call SETTAGSLOT(scrtagl,8,TAG_DONE,'n',0) 
  153.  
  154. return scrtagl
  155.  
  156.