Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

scimage.h

Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef SCIMAGE_H
00008 #define SCIMAGE_H
00009 
00010 #include "scconfig.h"
00011 #include "scribusapi.h"
00012 #include "scimagestructs.h"
00013 
00014 #ifdef HAVE_UNISTD_H
00015 #include <unistd.h>
00016 #endif
00017 #include <QImage>
00018 #include <QString>
00019 #include <QDataStream>
00020 #include <QMap>
00021 #include <QList>
00022 #include <QVector>
00023 #include <QFile>
00024 #include <QDir>
00025 #include <QStringList>
00026 
00027 #include "fpointarray.h"
00028 #include "sccolor.h"
00029 
00030 class ScribusDoc;
00031 class ScStreamFilter;
00032 class CMSettings;
00033 
00034 class SCRIBUS_API ScImage : private QImage
00035 {
00036 public:
00037     ScImage();
00038     ScImage(const QImage & image);
00039     ScImage(const ScImage & image);
00040     ScImage( int width, int height );
00041     ~ScImage();
00042 
00043     enum RequestType
00044     {
00045         CMYKData = 0,
00046         RGBData = 1,
00047         RGBProof = 2,
00048         RawData = 3,
00049         Thumbnail = 4,
00050     };
00051 
00052     enum ImageEffectCode
00053     {
00054         EF_INVERT = 0,
00055         EF_GRAYSCALE = 1,
00056         EF_COLORIZE = 2,
00057         EF_BRIGHTNESS = 3,
00058         EF_CONTRAST = 4,
00059         EF_SHARPEN = 5,
00060         EF_BLUR = 6,
00061         EF_SOLARIZE = 7,
00062         EF_DUOTONE = 8,
00063         EF_TRITONE = 9,
00064         EF_QUADTONE = 10,
00065         EF_GRADUATE = 11
00066     };
00067 
00068     void initialize();
00069 
00070     const QImage& qImage();
00071     QImage* qImagePtr();
00072     QImage scaled(int h, int w, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation) const;
00073     
00074     int height() const { return QImage::height(); }
00075     int width() const { return QImage::width(); }
00076     bool hasAlpha() const { return QImage::hasAlphaChannel(); }
00077     
00078     // Routines for PDF/PS output of images
00079     QByteArray ImageToArray();
00080     QByteArray ImageToGray();
00081     QByteArray ImageToCMYK_PS(int pl);
00082     QByteArray ImageToCMYK_PDF();
00083 
00084     bool writePSImageToFilter(ScStreamFilter* filter, int pl);
00085     bool writePSImageToFilter(ScStreamFilter* filter, const QByteArray& mask, int pl);
00086 
00087     bool getAlpha(QString fn, QByteArray& alpha, bool PDF, bool pdf14, int gsRes = 72, int scaleXSize = 0, int scaleYSize = 0);
00088     void Convert2JPG(QString fn, int Quality, bool isCMYK, bool isGray);
00089 
00090     // Image effects
00091     void applyEffect(const ScImageEffectList& effectsList, ColorList& colors, bool cmyk);
00092 
00093     // Generate a low res image for user preview
00094     void createLowRes(double scale);
00095 
00096     // Scale this image in-place
00097     void scaleImage(int width, int height);
00098 
00099     // Retrieve an embedded ICC profile from the file path `fn', storing it in `profile'.
00100     // TODO: Bad API. Should probably be static member returning an ICCProfile (custom class) or something like that.
00101     void getEmbeddedProfile(const QString & fn, QByteArray *profile, int *components);
00102 
00103     // Load an image into this ScImage instance
00104     // TODO: document params, split into smaller functions
00105     bool LoadPicture(const QString & fn, const CMSettings& cmSettings, bool useEmbedded, bool useProf, RequestType requestType, int gsRes, bool *realCMYK = 0, bool showMsg = false);
00106 
00107     ImageInfoRecord imgInfo;
00108 
00109 private:
00110 
00111     // Image effects
00112     void solarize(double factor, bool cmyk);
00113     void blur(int radius = 0);
00114     void sharpen(double radius= 0.0, double sigma = 1.0);
00115     void contrast(int contrastValue, bool cmyk);
00116     void brightness(int brightnessValue, bool cmyk);
00117     void invert(bool cmyk);
00118     void colorize(ScribusDoc* doc, ScColor color, int shade, bool cmyk);
00119     void duotone(ScribusDoc* doc, ScColor color1, int shade1, FPointArray curve1, bool lin1, ScColor color2, int shade2, FPointArray curve2, bool lin2, bool cmyk);
00120     void tritone(ScribusDoc* doc, ScColor color1, int shade1, FPointArray curve1, bool lin1, ScColor color2, int shade2, FPointArray curve2, bool lin2, ScColor color3, int shade3, FPointArray curve3, bool lin3, bool cmyk);
00121     void quadtone(ScribusDoc* doc, ScColor color1, int shade1, FPointArray curve1, bool lin1, ScColor color2, int shade2, FPointArray curve2, bool lin2, ScColor color3, int shade3, FPointArray curve3, bool lin3, ScColor color4, int shade4, FPointArray curve4, bool lin4, bool cmyk);
00122     void toGrayscale(bool cmyk);
00123     void doGraduate(FPointArray curve, bool cmyk, bool linear);
00124     void swapRGBA();
00125     bool convolveImage(QImage *dest, const unsigned int order, const double *kernel);
00126     int getOptimalKernelWidth(double radius, double sigma);
00127     void applyCurve(bool cmyk);
00128     char* iccbuf;
00129     uint icclen;
00130     QVector<int> curveTable;
00131     QList<unsigned int> colorTable;
00132 };
00133 
00134 #endif
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.