sanfx

imageformats.mel

Dec 9th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Copyright (C) 1997-2011 Autodesk, Inc., and/or its licensors.
  2. // All rights reserved.
  3. //
  4. // The coded instructions, statements, computer programs, and/or related
  5. // material (collectively the "Data") in these files contain unpublished
  6. // information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors,
  7. // which is protected by U.S. and Canadian federal copyright law and by
  8. // international treaties.
  9. //
  10. // The Data is provided for use exclusively by You. You have the right to use,
  11. // modify, and incorporate this Data into other products for purposes authorized
  12. // by the Autodesk software license agreement, without fee.
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK
  14. // DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES
  15. // INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT,
  16. // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE
  17. // OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS
  18. // LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL,
  19. // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS
  20. // LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
  21.  
  22. //==================================================================
  23. //
  24. // Set up the global arrays that contain the image format extensions.
  25. // This has to be separated from the Menu building
  26. // code, because other areas of Maya need to access these arrays and if
  27. // this is tied into the building of the menus, they can't do this.
  28. //
  29. // NOTE !!!! WARNING !!!!
  30. // If you make a change to the code in this procedure, you also need
  31. // to make the corresponding change in the 'createImageFile' procedure
  32. // of renderGlobalsWindow.mel.
  33. //
  34. // This code is also called from dynPaintMenus.mel since it may
  35. // be required for PFX canvas saving.
  36. //
  37. //==================================================================
  38. global string $imgExt[];  // This is the actual file extension
  39. global string $imfKey[];  // This is the unique imf keyword
  40.  
  41. // Custom formats, handled though user defined IMF plug-ins
  42. global string $imfPlugInExt[];
  43. global string $imfPlugInKey[];
  44.  
  45. global proc createImageFormats()
  46. {
  47.     global string $imgExt[];  // This is the actual file extension
  48.     global string $imfKey[];  // This is the unique imf keyword
  49.     global string $imfPlugInExt[];
  50.     global string $imfPlugInKey[];
  51.     int $i;
  52.  
  53.     // These are the default formats that ship with Maya.
  54.     $i =  0; $imgExt[$i] = "gif";  $imfKey[$i] = "gif";
  55.     $i =  1; $imgExt[$i] = "pic";  $imfKey[$i] = "si";
  56.     $i =  2; $imgExt[$i] = "rla";  $imfKey[$i] = "rla";
  57.     $i =  3; $imgExt[$i] = "tif";  $imfKey[$i] = "tif";
  58.     $i =  4; $imgExt[$i] = "tif";  $imfKey[$i] = "tif";
  59.     $i =  5; $imgExt[$i] = "sgi";  $imfKey[$i] = "sgi";
  60.     $i =  6; $imgExt[$i] = "als";  $imfKey[$i] = "als";
  61.     $i =  7; $imgExt[$i] = "iff";  $imfKey[$i] = "maya";
  62.     $i =  8; $imgExt[$i] = "jpeg"; $imfKey[$i] = "jpg";
  63.     $i =  9; $imgExt[$i] = "eps";  $imfKey[$i] = "eps";
  64.     $i = 10; $imgExt[$i] = "iff";  $imfKey[$i] = "maya";
  65.     $i = 11; $imgExt[$i] = "cin";  $imfKey[$i] = "cin";
  66.     $i = 12; $imgExt[$i] = "yuv";  $imfKey[$i] = "yuv";
  67.     // 14-18 are not used any more
  68.     $i = 19; $imgExt[$i] = "tga";  $imfKey[$i] = "tga";
  69.     $i = 20; $imgExt[$i] = "bmp";  $imfKey[$i] = "bmp";
  70.     $i = 31; $imgExt[$i] = "psd";  $imfKey[$i] = "psd";
  71.     $i = 32; $imgExt[$i] = "png";  $imfKey[$i] = "png";
  72.     $i = 35; $imgExt[$i] = "dds";  $imfKey[$i] = "dds";
  73.     $i = 36; $imgExt[$i] = "psd";  $imfKey[$i] = "psdLayered";
  74.  
  75.     if (`about -mac`)   {
  76.         $i = 30; $imgExt[$i] = "pntg"; $imfKey[$i] = "pntg";
  77.         $i = 33; $imgExt[$i] = "pict"; $imfKey[$i] = "pict";
  78.         $i = 34; $imgExt[$i] = "qtif"; $imfKey[$i] = "qtif";
  79.         $i = 22; $imgExt[$i] = "mov";   $imfKey[$i] = "qt";
  80.     }
  81.     $i = 13; $imgExt[$i] = "sgi";  $imfKey[$i] = "sgi";
  82.     if (`about -nt`) {
  83.         $i = 23; $imgExt[$i] = "avi"; $imfKey[$i]  = "avi";
  84.     }
  85.  
  86.     // Now register the formats found in IMF plug-ins
  87.     string $ext, $key;
  88.     int $size;
  89.     int $last = 0;
  90.     global string $imfPlugins[];
  91.     $size = size($imfKey);
  92.     $imfPlugins = sort(`imfPlugins -q`);
  93.  
  94.     for ($i=0; $i<size($imfPlugins); $i++) {
  95.         $key = `imfPlugins -q -key $imfPlugins[$i]`;
  96.         if (($key == "") || (!(`imfPlugins -q -writeSupport $key`))) {
  97.             continue;
  98.         }
  99.  
  100.         $found = 0;
  101.         for ($j=0; $j<$size; $j++) {
  102.             if ($key == $imfKey[$j]) { $found = 1; break; }
  103.         }
  104.         if (!$found) {
  105.             for ($j=0; $j<$last; $j++) {
  106.                 if ($key == $imfPlugInKey[$j]) { $found = 1; break; }
  107.             }
  108.         }
  109.  
  110.         if (! $found) {
  111.             // imf info is not present in the above hardcoded $imfKey
  112.             // array.  Hence append imf values to $imgExt, $imfKey and
  113.             // $imfExtNum arrays.
  114.             //
  115.             $ext = `imfPlugins -q -ext $imfPlugins[$i]`;
  116.             int $sizeOfExt = size($ext);
  117.             $imfPlugInExt[$last] = `substring $ext 2 $sizeOfExt`; // remove leading .
  118.             $imfPlugInKey[$last] = $key;
  119.             $last++;
  120.         }
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment