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.

imagedump.h 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 1995-2010 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. #ifndef IMG_IMAGEDUMP_H
  9. #define IMG_IMAGEDUMP_H
  10. #ifdef IMG_DUMP_TO_BMP
  11. /** Saves a bitmap to disk in .bmp format.
  12. *
  13. * @param bitmap - bitmap to save.
  14. * @param file_path - full absolute path to file where the file will be saved.
  15. * If this file already exists it will NOT be overwritten and the function will return OpStatus::ERR.
  16. * @param blend_to_grid - if TRUE then the background for the transparent parts
  17. * of the bitmap will be light/dark checkboard, else it will be white.
  18. * @return OK if success or any valid error returned by OpFile when writing.
  19. */
  20. OP_STATUS DumpOpBitmap(OpBitmap* bitmap, const uni_char* file_path, BOOL blend_to_grid);
  21. OP_STATUS DumpOpBitmap(OpBitmap* bitmap, OpFileDescriptor& opened_file, BOOL blend_to_grid);
  22. #endif // IMG_DUMP_TO_BMP
  23. #ifdef MINPNG_ENCODER
  24. /** saves the bitmap to disk in .png format.
  25. *
  26. * @param bitmap - bitmap to save.
  27. * @param file_path - full absolute path to file where the file will be saved.
  28. * @param allow_overwrite - if FALSE and file_path already exists it
  29. * will NOT be overwritten and the function will return
  30. * OpStatus::ERR. if TRUE file_path will be overwritten if it
  31. * already exists.
  32. * @return OK if success or any valid error returned by OpFile when writing.
  33. */
  34. OP_STATUS DumpOpBitmapToPNG(OpBitmap* bitmap, const uni_char* file_path, BOOL allow_overwrite = FALSE);
  35. OP_STATUS DumpOpBitmapToPNG(OpBitmap* bitmap, OpFileDescriptor& opened_file);
  36. #endif // MINPNG_ENCODER
  37. #ifdef IMG_BITMAP_TO_BASE64PNG
  38. /** Get a string representing the content of the canvas as a base-64
  39. * encoded string with the png representation of the content.
  40. *
  41. * @param bitmap - OpBitmap to convert (must be non-NULL)
  42. * @param buffer a pointer to a TempBuffer where the output is stored.
  43. * @returns OpStatus::OK on success, an error otherwise.
  44. */
  45. OP_STATUS GetOpBitmapAsBase64PNG(OpBitmap* bitmap, TempBuffer* buffer);
  46. OP_STATUS GetNonPremultipliedBufferAsBase64PNG(UINT32* pixels, unsigned int width, unsigned int height, TempBuffer* buffer);
  47. #endif // IMG_BITMAP_TO_BASE64PNG
  48. #ifdef IMG_BITMAP_TO_BASE64JPG
  49. /** Get a string representing the content of the canvas as a base-64
  50. * encoded string with the jpg representation of the content. when
  51. * passed a bitmap with transparency, this function adheres to
  52. * <canvas> semantics - ie the bitmap is composited onto a solid black
  53. * background.
  54. *
  55. * @param bitmap - OpBitmap to convert (must be non-NULL)
  56. * @param buffer a pointer to a TempBuffer where the output is stored.
  57. * @param quality the quality, in percent (1-100), of the produced jpg image.
  58. * @returns OpStatus::OK on success, an error otherwise.
  59. */
  60. OP_STATUS GetOpBitmapAsBase64JPG(OpBitmap* bitmap, TempBuffer* buffer, int quality = 85);
  61. OP_STATUS GetNonPremultipliedBufferAsBase64JPG(UINT32* pixels, unsigned int width, unsigned int height, TempBuffer* buffer, int quality = 85);
  62. #endif // IMG_BITMAP_TO_BASE64JPG
  63. #endif // IMG_IMAGEDUMP_H