etc1.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2009 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // This is branched from AOSP's frameworks/base/opengl/include/ETC1/etc1.h
  15. //
  16. // It has been modified to implement Chromium's ETC1 API. The decoding path
  17. // has been removed as we do not require it.
  18. #ifndef THIRD_PARTY_ANDROID_OPENGL_ETC1_ETC1_H_
  19. #define THIRD_PARTY_ANDROID_OPENGL_ETC1_ETC1_H_
  20. // Return the size of the encoded image data.
  21. unsigned int etc1_get_encoded_data_size(unsigned int width, unsigned int height);
  22. // Encode an entire image.
  23. // pIn - pointer to the image data. Formatted such that
  24. // pixel (x,y) is at pIn + pixelSize * x + stride * y;
  25. // pOut - pointer to encoded data. Must be large enough to store entire encoded image.
  26. // pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
  27. // returns non-zero if there is an error.
  28. bool etc1_encode_image(const unsigned char* pIn, unsigned int width, unsigned int height,
  29. unsigned int pixelSize, unsigned int stride, unsigned char* pOut, unsigned int outWidth,
  30. unsigned int outHeight);
  31. // Decode an entire image.
  32. // pIn - pointer to encoded data.
  33. // pOut - pointer to the image data. Will be written such that
  34. // pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be
  35. // large enough to store entire image.
  36. // pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
  37. // returns false if there is an error.
  38. bool etc1_decode_image(const unsigned char* pIn, unsigned char* pOut,
  39. unsigned int width, unsigned int height,
  40. unsigned int pixelSize, unsigned int stride);
  41. // Size of a PKM header, in bytes.
  42. #define ETC_PKM_HEADER_SIZE 16
  43. // Format a PKM header
  44. void etc1_pkm_format_header(unsigned char* pHeader, unsigned int width, unsigned int height);
  45. // Check if a PKM header is correctly formatted.
  46. bool etc1_pkm_is_valid(const unsigned char* pHeader);
  47. // Read the image width from a PKM header
  48. unsigned int etc1_pkm_get_width(const unsigned char* pHeader);
  49. // Read the image height from a PKM header
  50. unsigned int etc1_pkm_get_height(const unsigned char* pHeader);
  51. #endif // THIRD_PARTY_ANDROID_OPENGL_ETC1_ETC1_H_