Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imagecolormanager.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 1995-2011 Opera Software AS. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser. It may not be distributed
  6. ** under any circumstances.
  7. **
  8. */
  9. #ifndef IMAGECOLORMANAGER_H
  10. #define IMAGECOLORMANAGER_H
  11. /**
  12. * Opaque object representing an ICC color profile.
  13. *
  14. * Can be either an input profile (as acquired from image decoders) or
  15. * an output profile (generally the screen profile - sRGB in some
  16. * form). Could theoretically also be other types of profiles as
  17. * defined by the ICC specification, but there is currently no need
  18. * for those.
  19. */
  20. class ICCProfile
  21. {
  22. public:
  23. virtual ~ICCProfile() {}
  24. };
  25. /**
  26. * A transform from one (ICC) profile to another (ICC) profile.
  27. *
  28. * This is the workhorse for colorspace transformations. In general
  29. * terms, it forms the connection between an input profile and an
  30. * output profile.
  31. */
  32. class ImageColorTransform
  33. {
  34. public:
  35. virtual ~ImageColorTransform() {}
  36. /**
  37. * Apply the colorspace transformation to run of pixels.
  38. *
  39. * Applies the transform from the input colorspace to the output
  40. * colorspace. Hence, the source/input data is assumed to be in
  41. * the input colorspace, while the destination/output data is
  42. * assumed to be in the output colorspace.
  43. *
  44. * The pixel format used is BGRA8888 (same as for
  45. * OpBitmap::AddLine and friends).
  46. *
  47. * In-place transformation should be supported (i.e, when dst ==
  48. * src).
  49. *
  50. * @param[out] dst Buffer where the transformed pixels are written.
  51. * @param[in] src Buffer of pixels to transform.
  52. * @param[in] length The number of pixels to transform. Both the
  53. * source and destination buffers must be able to
  54. * store at least this amount of pixels.
  55. */
  56. virtual void Apply(UINT32* dst, const UINT32* src, unsigned length) = 0;
  57. /**
  58. * Apply the colorspace transformation to run of pixels.
  59. *
  60. * Applies the color transform to temporary buffer and return the
  61. * result. The result is owned by the callee, and should be copied immediately
  62. *
  63. * @param[in] src Buffer of pixels to transform.
  64. * @param[in] length The number of pixels to transform. Both the
  65. * source and destination buffers must be able to
  66. * store at least this amount of pixels.
  67. * @return dst Buffer where the transformed pixels are written. NULL if fail.
  68. */
  69. virtual UINT32* Apply(const UINT32* src, unsigned length) = 0;
  70. };
  71. /**
  72. * Manager for decoding of ICC profiles and creation of color transforms.
  73. */
  74. class ImageColorManager
  75. {
  76. public:
  77. static ImageColorManager* Create();
  78. virtual ~ImageColorManager() {}
  79. /**
  80. * Create an ICC profile from a blob of data.
  81. *
  82. * Create a color profile object representing the ICC color
  83. * profile that is stored in the block of length datalen pointed
  84. * to by data.
  85. *
  86. * @param[out] profile The color profile object.
  87. * @param[in] data The ICC profile data.
  88. * @param[in] datalen The length of the datablock in bytes.
  89. *
  90. * @return OpStatus::OK on success, OpStatus::ERR if the profile
  91. * data was invalid, and OpStatus::ERR_NO_MEMORY if OOM
  92. * was encountered.
  93. */
  94. virtual OP_STATUS CreateProfile(ICCProfile** profile, const UINT8* data, unsigned datalen) = 0;
  95. /**
  96. * Create a transform from one color profile to another.
  97. *
  98. * Create a color transform object that allows pixels to be
  99. * transformed from the input/source colorspace to the
  100. * output/destination colorspace.
  101. *
  102. * @see ImageColorTransform for usage.
  103. *
  104. * Profiles may be disposed of/deleted after a color transform was
  105. * successfully created.
  106. *
  107. * @param[out] transform The color transform.
  108. * @param[in] src The input/source profile.
  109. * @param[in] dst The output/destination profile, NULL means use the device profile.
  110. *
  111. * @return OpStatus::OK on success, OpStatus::ERR if some error
  112. * was encountered while trying to create the color
  113. * transform ("connect the
  114. * profiles"). OpStatus::ERR_NO_MEMORY on OOM.
  115. */
  116. virtual OP_STATUS CreateTransform(ImageColorTransform** transform, ICCProfile* src, ICCProfile* dst = NULL) = 0;
  117. };
  118. #endif // IMAGECOLORMANAGER_H