home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Arashi 1.1.1 / source code / For your think c folder / Misc / StripPictComments.c < prev   
Encoding:
C/C++ Source or Header  |  1994-01-13  |  1.6 KB  |  87 lines  |  [TEXT/KAHL]

  1. /*/
  2.      Project Arashi: StripPictComments.c
  3.      Major release: Version 1.1d2, 9/5/95
  4.  
  5.      Last modification: Thursday, January 13, 1994, 8:08
  6.      Created: Wednesday, December 1, 1993, 20:08
  7.  
  8.      Copyright © 1993-1994, Juri Munkki
  9. /*/
  10.  
  11. static
  12. pascal
  13. void    NoComment(
  14.     short    kind,
  15.     short    dataSize,
  16.     Handle    theHandle)
  17. {
  18. #ifdef PRESERVECOMMENTS
  19.     if(kind != kCommentKind)
  20.     {    StdComment(kind, dataSize, theHandle);
  21.     }
  22. #endif
  23. }
  24.  
  25. void    StripPictComments(
  26.     short    resId)
  27. {
  28.     CGrafPort    tempPort;
  29.     GrafPtr        saved;
  30.     PicHandle    oldPic;
  31.     PicHandle    newPic;
  32.     Rect        bounds;
  33.     long        regSize, picSize;
  34.     short        i;
  35.     CQDProcsPtr    theProcs;
  36.     
  37.     GetPort(&saved);
  38.     
  39.     OpenCPort(&tempPort);
  40.     SetPort(&tempPort);
  41.     PortSize(0,0);
  42.  
  43.     theProcs = (CQDProcsPtr) NewPtr(sizeof(CQDProcs));
  44.     SetStdCProcs(theProcs);
  45.     theProcs->commentProc = (void *)NoComment;
  46.     
  47.     tempPort.grafProcs = (void *)theProcs;
  48.  
  49.     oldPic = GetPicture(resId);
  50.     bounds = (*oldPic)->picFrame;
  51.     
  52.     newPic = OpenPicture(&bounds);
  53.     ClipRect(&bounds);
  54.     DrawPicture(oldPic, &bounds);
  55.  
  56.     ClosePicture();
  57.     SetPort(saved);
  58.     ClosePort(&tempPort);
  59.     DisposeHandle(theProcs);
  60.     
  61.     picSize = GetHandleSize(newPic);
  62.     SetHandleSize(oldPic, picSize);
  63.     picSize = GetHandleSize(oldPic);
  64.     BlockMove(*newPic, *oldPic, picSize);
  65.     ChangedResource(oldPic);
  66.     WriteResource(oldPic);
  67.     KillPicture(newPic);
  68.     ReleaseResource(oldPic);
  69. }
  70.  
  71. void    StripAllPictComments()
  72. {
  73.     short    counter;
  74.     Handle    thePic;
  75.     short    theId;
  76.     OSType    theType;
  77.     Str255    theName;
  78.     
  79.     counter = Count1Resources('PICT');
  80.     
  81.     while(counter)
  82.     {
  83.         thePic = Get1IndResource('PICT', counter--);
  84.         GetResInfo(thePic, &theId, &theType, theName);
  85.         StripPictComments(theId);
  86.     }
  87. }