Subject: how to display a JPEG image and resize it.

by Marco Perrotti 12 February 1996 Introduction:

you can use Media Control Interface (MCI) commands to display .JPG files.

Steps:

first of all, you've to install QuickTime for Windows (also called QTW). Your ToolBook CD Rom contains QTW files (directory drivers\qtw). To install it, just choose "setup.exe". Then draw an object (ex. a rectangle) and call it "dummy". Put following code in a button script.

Script:

to handle buttonClick
   get moveWindow is in DllFunctions("user")
   if not(it)
      linkDll "user"
	 INT moveWindow(WORD,INT,INT,INT,INT,INT)
      end linkDll
   end if
   get clientFromPage is in DllFunctions("tb30win.dll")
   if not(it)
      linkDll "tb30win.dll"
	 STRING clientFromPage(WORD,STRING,INT,STRING)
      end linkDll
   end if
   get openDlg is in DllFunctions("tb30dlg.dll")
   if not(it)
      linkDll "tb30dlg.dll"
         STRING openDlg(STRING,STRING,STRING,STRING)
      end linkDll
   end if
   clear sysError
   get openDlg(".","*.jpg","Choose a .JPG file"," ")
   if sysError is -1
      break to system
   end if
   set whichPhoto to it
   get callMCI("close all")
   get callMCI("open" && whichPhoto && \
   "alias photo style child parent" && sysWindowHandle)
   set hWnd to callMCI("status photo window handle")
   set dimWhere to clientFromPage(sysWindowHandle, \
   sysPageScroll, sysMagnification,\
   bounds of rectangle dummy of this page)
   set x to item 1 of dimWhere
   set y to item 2 of dimWhere
   set nWidth to item 3 of dimWhere - item 1 of dimWhere
   set nHeight to item 4 of dimWhere - item 2 of dimWhere
   get moveWindow(hWnd,x,y,nWidth,nHeight,1)

   -- Image resize

   get callMCI("put photo destination at 0 0"\
   && nWidth && nHeight)
   get callMCI("play photo")
end