SkJpegUtility.h 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SkJpegUtility_codec_DEFINED
  8. #define SkJpegUtility_codec_DEFINED
  9. #include "include/core/SkStream.h"
  10. #include "src/codec/SkJpegPriv.h"
  11. #include <setjmp.h>
  12. // stdio is needed for jpeglib
  13. #include <stdio.h>
  14. extern "C" {
  15. #include "jpeglib.h"
  16. #include "jerror.h"
  17. }
  18. /*
  19. * Error handling function
  20. */
  21. void skjpeg_err_exit(j_common_ptr cinfo);
  22. /*
  23. * Source handling struct for that allows libjpeg to use our stream object
  24. */
  25. struct skjpeg_source_mgr : jpeg_source_mgr {
  26. skjpeg_source_mgr(SkStream* stream);
  27. SkStream* fStream; // unowned
  28. enum {
  29. // TODO (msarett): Experiment with different buffer sizes.
  30. // This size was chosen because it matches SkImageDecoder.
  31. kBufferSize = 1024
  32. };
  33. uint8_t fBuffer[kBufferSize];
  34. };
  35. #endif