Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 10:26:10

0001 //========================================================================
0002 //
0003 // SplashBitmap.h
0004 //
0005 //========================================================================
0006 
0007 //========================================================================
0008 //
0009 // Modified under the Poppler project - http://poppler.freedesktop.org
0010 //
0011 // All changes made under the Poppler project to this file are licensed
0012 // under GPL version 2 or later
0013 //
0014 // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com>
0015 // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
0016 // Copyright (C) 2009, 2012, 2018, 2021, 2022 Albert Astals Cid <aacid@kde.org>
0017 // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
0018 // Copyright (C) 2010, 2017 Adrian Johnson <ajohnson@redneon.com>
0019 // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org>
0020 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
0021 // Copyright (C) 2010 William Bader <williambader@hotmail.com>
0022 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
0023 // Copyright (C) 2015 Adam Reichold <adamreichold@myopera.com>
0024 // Copyright (C) 2016 Kenji Uno <ku@digitaldolphins.jp>
0025 // Copyright (C) 2018 Martin Packman <gzlist@googlemail.com>
0026 // Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de>
0027 //
0028 // To see a description of the changes please see the Changelog file that
0029 // came with your tarball or type make ChangeLog if you are building from git
0030 //
0031 //========================================================================
0032 
0033 #ifndef SPLASHBITMAP_H
0034 #define SPLASHBITMAP_H
0035 
0036 #include "SplashTypes.h"
0037 #include "poppler_private_export.h"
0038 #include <cstdio>
0039 #include <string>
0040 #include <vector>
0041 
0042 class ImgWriter;
0043 class GfxSeparationColorSpace;
0044 
0045 //------------------------------------------------------------------------
0046 // SplashBitmap
0047 //------------------------------------------------------------------------
0048 
0049 class POPPLER_PRIVATE_EXPORT SplashBitmap
0050 {
0051 public:
0052     // Create a new bitmap.  It will have <widthA> x <heightA> pixels in
0053     // color mode <modeA>.  Rows will be padded out to a multiple of
0054     // <rowPad> bytes.  If <topDown> is false, the bitmap will be stored
0055     // upside-down, i.e., with the last row first in memory.
0056     SplashBitmap(int widthA, int heightA, int rowPad, SplashColorMode modeA, bool alphaA, bool topDown = true, const std::vector<GfxSeparationColorSpace *> *separationList = nullptr);
0057     static SplashBitmap *copy(const SplashBitmap *src);
0058 
0059     ~SplashBitmap();
0060 
0061     SplashBitmap(const SplashBitmap &) = delete;
0062     SplashBitmap &operator=(const SplashBitmap &) = delete;
0063 
0064     int getWidth() const { return width; }
0065     int getHeight() const { return height; }
0066     int getRowSize() const { return rowSize; }
0067     int getAlphaRowSize() const { return width; }
0068     int getRowPad() const { return rowPad; }
0069     SplashColorMode getMode() const { return mode; }
0070     SplashColorPtr getDataPtr() { return data; }
0071     unsigned char *getAlphaPtr() { return alpha; }
0072     std::vector<GfxSeparationColorSpace *> *getSeparationList() { return separationList; }
0073     SplashColorConstPtr getDataPtr() const { return data; }
0074     const unsigned char *getAlphaPtr() const { return alpha; }
0075     const std::vector<GfxSeparationColorSpace *> *getSeparationList() const { return separationList; }
0076 
0077     SplashError writePNMFile(char *fileName);
0078     SplashError writePNMFile(FILE *f);
0079     SplashError writeAlphaPGMFile(char *fileName);
0080 
0081     struct WriteImgParams
0082     {
0083         int jpegQuality = -1;
0084         bool jpegProgressive = false;
0085         std::string tiffCompression;
0086         bool jpegOptimize = false;
0087     };
0088 
0089     SplashError writeImgFile(SplashImageFileFormat format, const char *fileName, double hDPI, double vDPI, WriteImgParams *params = nullptr);
0090     SplashError writeImgFile(SplashImageFileFormat format, FILE *f, double hDPI, double vDPI, WriteImgParams *params = nullptr);
0091     SplashError writeImgFile(ImgWriter *writer, FILE *f, double hDPI, double vDPI, SplashColorMode imageWriterFormat);
0092 
0093     enum ConversionMode
0094     {
0095         conversionOpaque,
0096         conversionAlpha,
0097         conversionAlphaPremultiplied
0098     };
0099 
0100     bool convertToXBGR(ConversionMode conversionMode = conversionOpaque);
0101 
0102     void getPixel(int x, int y, SplashColorPtr pixel);
0103     void getRGBLine(int y, SplashColorPtr line);
0104     void getXBGRLine(int y, SplashColorPtr line, ConversionMode conversionMode = conversionOpaque);
0105     void getCMYKLine(int y, SplashColorPtr line);
0106     unsigned char getAlpha(int x, int y);
0107 
0108     // Caller takes ownership of the bitmap data.  The SplashBitmap
0109     // object is no longer valid -- the next call should be to the
0110     // destructor.
0111     SplashColorPtr takeData();
0112 
0113 private:
0114     int width, height; // size of bitmap
0115     int rowPad;
0116     int rowSize; // size of one row of data, in bytes
0117                  //   - negative for bottom-up bitmaps
0118     SplashColorMode mode; // color mode
0119     SplashColorPtr data; // pointer to row zero of the color data
0120     unsigned char *alpha; // pointer to row zero of the alpha data
0121                           //   (always top-down)
0122     std::vector<GfxSeparationColorSpace *> *separationList; // list of spot colorants and their mapping functions
0123 
0124     friend class Splash;
0125 
0126     void setJpegParams(ImgWriter *writer, WriteImgParams *params);
0127 };
0128 
0129 #endif