2
0

vericc.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //---------------------------------------------------------------------------------
  2. //
  3. // Little Color Management System
  4. // Copyright (c) 1998-2010 Marti Maria Saguer
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining
  7. // a copy of this software and associated documentation files (the "Software"),
  8. // to deal in the Software without restriction, including without limitation
  9. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. // and/or sell copies of the Software, and to permit persons to whom the Software
  11. // is furnished to do so, subject to the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in
  14. // all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  18. // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. //
  24. //---------------------------------------------------------------------------------
  25. //
  26. #include "lcms2.h"
  27. #include <string.h>
  28. #include <math.h>
  29. static
  30. int PrintUsage(void)
  31. {
  32. fprintf(stderr, "Sets profile version\n\nUsage: vericc --r<version> iccprofile.icc\n");
  33. return 0;
  34. }
  35. int main(int argc, char *argv[])
  36. {
  37. cmsHPROFILE hProfile;
  38. char* ptr;
  39. cmsFloat64Number Version;
  40. if (argc != 3) return PrintUsage();
  41. ptr = argv[1];
  42. if (strncmp(ptr, "--r", 3) != 0) return PrintUsage();
  43. ptr += 3;
  44. if (!*ptr) { fprintf(stderr, "Wrong version number\n"); return 1; }
  45. Version = atof(ptr);
  46. hProfile = cmsOpenProfileFromFile(argv[2], "r");
  47. if (hProfile == NULL) { fprintf(stderr, "'%s': cannot open\n", argv[2]); return 1; }
  48. cmsSetProfileVersion(hProfile, Version);
  49. cmsSaveProfileToFile(hProfile, "$$tmp.icc");
  50. cmsCloseProfile(hProfile);
  51. remove(argv[2]);
  52. rename("$$tmp.icc", argv[2]);
  53. return 0;
  54. }