[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to resize PICT using GWorlds (fwd)



Marty Kenner (makenner@mmm.com) writes about problems creating a picture:
 I am again (still?) working on an application making heavy use of PICTs
 and I need to be able to scale a PICT and write it to a file.

  I was trying to do what I do in C -
 
        get source picture from file
        create an offscreen GWorld
        lock its pixels
        cliprect the target rectangle
        draw the source PICT into the target rectangle
        open a new PICT
        copybits the pixmap of the offscreen GWorld onto itself
        close the new PICT and write to file
  ...
  with the result that the picture is damaged and contains garbage 
  (unimplemented commands).

He then mentions that he uses the oodles of utils calls to create the
GWorld and using the call to copy bits.

One solution is to use the pict-svm and resource-svm methods for drawing
scaled versions of pictures (and pict resources).  The code is in oodles-of
utils in the mixin-madness in simple-view-mixins. Another way is to
use the following steps:
	get source picture from file
	cliprect the target rectangle
	create a picture:
	  #_openPicture (with the appropriate rect)
	  #_drawPicture (with the appropriate rect for scaling)
	  #_closePicture
	  return the resulting picture
        write the picture to the file
The resulting picture is a true picture with all of the calls in
place. If you're picture is color you'll have to use the correct
color "window". For an example of a program that saves and restores
portions of the screen bit map, see menu-enhancements.hqx (in
the contrib directory) which contains oou-utils.lisp.

mark