This commit is contained in:
Luis Ángel San Martín
2017-11-26 07:39:08 +01:00
73 changed files with 4550 additions and 3404 deletions

View File

@ -44,7 +44,7 @@ const QStringList Comic::literalComicExtensions = LiteralComicArchiveExtensions;
//-----------------------------------------------------------------------------
Comic::Comic()
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false),_invalidated(false)
{
setup();
}
@ -57,6 +57,7 @@ Comic::Comic(const QString & pathFile, int atPage )
//-----------------------------------------------------------------------------
Comic::~Comic()
{
emit destroyed();
delete bm;
}
//-----------------------------------------------------------------------------
@ -198,7 +199,13 @@ void Comic::updateBookmarkImage(int index)
//-----------------------------------------------------------------------------
void Comic::setPageLoaded(int page)
{
_loadedPages[page] = true;
_loadedPages[page] = true;
}
void Comic::invalidate()
{
_invalidated = true;
emit invalidated();
}
//-----------------------------------------------------------------------------
QByteArray Comic::getRawPage(int page)
@ -585,10 +592,20 @@ void FileComic::process()
for(int i = sectionIndex; i<sections.count() ; i++)
{
if(_invalidated)
{
moveToThread(QCoreApplication::instance()->thread());
return;
}
archive.getAllData(sections.at(i),this);
}
for(int i = 0; i<sectionIndex; i++)
{
if(_invalidated)
{
moveToThread(QCoreApplication::instance()->thread());
return;
}
archive.getAllData(sections.at(i),this);
}
//archive.getAllData(QVector<quint32>(),this);
@ -688,6 +705,12 @@ void FolderComic::process()
int i=_firstPage;
while(count<nPages)
{
if(_invalidated)
{
moveToThread(QCoreApplication::instance()->thread());
return;
}
QFile f(list.at(i).absoluteFilePath());
f.open(QIODevice::ReadOnly);
_pages[i]=f.readAll();
@ -843,10 +866,23 @@ void PDFComic::process()
int buffered_index = _index;
for(int i=buffered_index;i<nPages;i++)
{
if(_invalidated)
{
delete pdfComic;
moveToThread(QCoreApplication::instance()->thread());
return;
}
renderPage(i);
}
for(int i=0;i<buffered_index;i++)
{
if(_invalidated)
{
delete pdfComic;
moveToThread(QCoreApplication::instance()->thread());
return;
}
renderPage(i);
}

View File

@ -38,6 +38,8 @@ class Comic : public QObject
bool _isPDF;
bool _invalidated;
public:
static const QStringList imageExtensions;
@ -79,7 +81,6 @@ class Comic : public QObject
static QList<QString> findValidComicFilesInFolder(const QString &path);
public slots:
void loadFinished();
void setBookmark();
void removeBookmark();
@ -87,9 +88,11 @@ class Comic : public QObject
void checkIsBookmark(int index);
void updateBookmarkImage(int);
void setPageLoaded(int page);
void invalidate();
signals:
void invalidated();
void destroyed();
void imagesLoaded();
void imageLoaded(int index);
void imageLoaded(int index,const QByteArray & image);

View File

@ -24,15 +24,15 @@ struct Preset defaultYACReaderFlowConfig = {
0.08f, //Animation_step sets the speed of the animation
1.5f, //Animation_speedup sets the acceleration of the animation
0.1f, //Animation_step_max sets the maximum speed of the animation
3.f, //Animation_Fade_out_dis sets the distance of view
3.f, //Animation_Fade_out_dis sets the distance of view
1.5f, //pre_rotation sets the rotation increasion
3.f, //View_rotate_light_strenght sets the light strenght on rotation
0.01f, //View_rotate_add sets the speed of the rotation
0.02f, //View_rotate_sub sets the speed of reversing the rotation
0.01f, //View_rotate_add sets the speed of the rotation
0.02f, //View_rotate_sub sets the speed of reversing the rotation
20.f, //View_angle sets the maximum view angle
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_Y the Y Position of the Coverflow
-8.f, //CF_Z the Z Position of the Coverflow
@ -43,7 +43,7 @@ struct Preset defaultYACReaderFlowConfig = {
-50.f, //Rotation sets the rotation of each cover
0.18f, //X_Distance sets the distance between the covers
1.f, //Center_Distance sets the distance between the centered and the non centered covers
0.1f, //Z_Distance sets the pushback amount
0.1f, //Z_Distance sets the pushback amount
0.0f, //Y_Distance sets the elevation amount
30.f //zoom level
@ -54,15 +54,15 @@ struct Preset presetYACReaderFlowClassicConfig = {
0.08f, //Animation_step sets the speed of the animation
1.5f, //Animation_speedup sets the acceleration of the animation
0.1f, //Animation_step_max sets the maximum speed of the animation
2.f, //Animation_Fade_out_dis sets the distance of view
2.f, //Animation_Fade_out_dis sets the distance of view
1.5f, //pre_rotation sets the rotation increasion
3.f, //View_rotate_light_strenght sets the light strenght on rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
30.f, //View_angle sets the maximum view angle
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_X the X Position of the Coverflow
-0.2f, //CF_Y the Y Position of the Coverflow
-7.f, //CF_Z the Z Position of the Coverflow
@ -73,9 +73,9 @@ struct Preset presetYACReaderFlowClassicConfig = {
-40.f, //Rotation sets the rotation of each cover
0.18f, //X_Distance sets the distance between the covers
1.f, //Center_Distance sets the distance between the centered and the non centered covers
0.1f, //Z_Distance sets the pushback amount
0.1f, //Z_Distance sets the pushback amount
0.0f, //Y_Distance sets the elevation amount
22.f //zoom level
};
@ -84,15 +84,15 @@ struct Preset presetYACReaderFlowStripeConfig = {
0.08f, //Animation_step sets the speed of the animation
1.5f, //Animation_speedup sets the acceleration of the animation
0.1f, //Animation_step_max sets the maximum speed of the animation
6.f, //Animation_Fade_out_dis sets the distance of view
6.f, //Animation_Fade_out_dis sets the distance of view
1.5f, //pre_rotation sets the rotation increasion
4.f, //View_rotate_light_strenght sets the light strenght on rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
30.f, //View_angle sets the maximum view angle
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_X the X Position of the Coverflow
-0.2f, //CF_Y the Y Position of the Coverflow
-7.f, //CF_Z the Z Position of the Coverflow
@ -103,7 +103,7 @@ struct Preset presetYACReaderFlowStripeConfig = {
0.f, //Rotation sets the rotation of each cover
1.1f, //X_Distance sets the distance between the covers
0.2f, //Center_Distance sets the distance between the centered and the non centered covers
0.01f, //Z_Distance sets the pushback amount
0.01f, //Z_Distance sets the pushback amount
0.0f, //Y_Distance sets the elevation amount
22.f //zoom level
@ -114,15 +114,15 @@ struct Preset presetYACReaderFlowOverlappedStripeConfig = {
0.08f, //Animation_step sets the speed of the animation
1.5f, //Animation_speedup sets the acceleration of the animation
0.1f, //Animation_step_max sets the maximum speed of the animation
2.f, //Animation_Fade_out_dis sets the distance of view
2.f, //Animation_Fade_out_dis sets the distance of view
1.5f, //pre_rotation sets the rotation increasion
3.f, //View_rotate_light_strenght sets the light strenght on rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
30.f, //View_angle sets the maximum view angle
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_X the X Position of the Coverflow
-0.2f, //CF_Y the Y Position of the Coverflow
-7.f, //CF_Z the Z Position of the Coverflow
@ -133,7 +133,7 @@ struct Preset presetYACReaderFlowOverlappedStripeConfig = {
0.f, //Rotation sets the rotation of each cover
0.18f, //X_Distance sets the distance between the covers
1.f, //Center_Distance sets the distance between the centered and the non centered covers
0.1f, //Z_Distance sets the pushback amount
0.1f, //Z_Distance sets the pushback amount
0.0f, //Y_Distance sets the elevation amount
22.f //zoom level
@ -144,15 +144,15 @@ struct Preset pressetYACReaderFlowUpConfig = {
0.08f, //Animation_step sets the speed of the animation
1.5f, //Animation_speedup sets the acceleration of the animation
0.1f, //Animation_step_max sets the maximum speed of the animation
2.5f, //Animation_Fade_out_dis sets the distance of view
2.5f, //Animation_Fade_out_dis sets the distance of view
1.5f, //pre_rotation sets the rotation increasion
3.f, //View_rotate_light_strenght sets the light strenght on rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
5.f, //View_angle sets the maximum view angle
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_X the X Position of the Coverflow
-0.2f, //CF_Y the Y Position of the Coverflow
-7.f, //CF_Z the Z Position of the Coverflow
@ -163,7 +163,7 @@ struct Preset pressetYACReaderFlowUpConfig = {
-50.f, //Rotation sets the rotation of each cover
0.18f, //X_Distance sets the distance between the covers
1.f, //Center_Distance sets the distance between the centered and the non centered covers
0.1f, //Z_Distance sets the pushback amount
0.1f, //Z_Distance sets the pushback amount
-0.1f, //Y_Distance sets the elevation amount
22.f //zoom level
@ -174,15 +174,15 @@ struct Preset pressetYACReaderFlowDownConfig = {
0.08f, //Animation_step sets the speed of the animation
1.5f, //Animation_speedup sets the acceleration of the animation
0.1f, //Animation_step_max sets the maximum speed of the animation
2.5f, //Animation_Fade_out_dis sets the distance of view
2.5f, //Animation_Fade_out_dis sets the distance of view
1.5f, //pre_rotation sets the rotation increasion
3.f, //View_rotate_light_strenght sets the light strenght on rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
0.08f, //View_rotate_add sets the speed of the rotation
0.08f, //View_rotate_sub sets the speed of reversing the rotation
5.f, //View_angle sets the maximum view angle
0.f, //CF_X the X Position of the Coverflow
0.f, //CF_X the X Position of the Coverflow
-0.2f, //CF_Y the Y Position of the Coverflow
-7.f, //CF_Z the Z Position of the Coverflow
@ -193,14 +193,14 @@ struct Preset pressetYACReaderFlowDownConfig = {
-50.f, //Rotation sets the rotation of each cover
0.18f, //X_Distance sets the distance between the covers
1.f, //Center_Distance sets the distance between the centered and the non centered covers
0.1f, //Z_Distance sets the pushback amount
0.1f, //Z_Distance sets the pushback amount
0.1f, //Y_Distance sets the elevation amount
22.f //zoom level
};
/*Constructor*/
YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p)
:QGLWidget(QGLFormat(QGL::SampleBuffers), parent),numObjects(0),lazyPopulateObjects(-1),bUseVSync(false),hasBeenInitialized(false)
:QGLWidget(QGLFormat(QGL::SampleBuffers), parent),numObjects(0),lazyPopulateObjects(-1),bUseVSync(false),hasBeenInitialized(false),flowRightToLeft(false)
{
updateCount = 0;
config = p;
@ -251,7 +251,7 @@ void YACReaderFlowGL::timerEvent(QTimerEvent * event)
{
if(timerId == event->timerId())
updateGL();
//if(!worker->isRunning())
//worker->start();
}
@ -354,6 +354,9 @@ void YACReaderFlowGL::udpatePerspective(int width, int height)
/*Private*/
void YACReaderFlowGL::calcPos(YACReader3DImage & image, int pos)
{
if(flowRightToLeft){
pos = pos * -1;
}
if(pos == 0){
image.current = centerPos;
}else{
@ -414,7 +417,7 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage & image)
float w = image.width;
float h = image.height;
//fadeout
//fadeout
float opacity = 1-1/(config.animationFadeOutDist+config.viewRotateLightStrenght*fabs(viewRotate))*fabs(0-image.current.x);
glLoadIdentity();
@ -492,7 +495,7 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage & image)
glEnd();
glDisable(GL_TEXTURE_2D);
if(showMarks && loaded[image.index] && marks[image.index] != Unread)
{
glEnable(GL_TEXTURE_2D);
@ -526,7 +529,7 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage & image)
glDisable(GL_TEXTURE_2D);
}
glPopMatrix();
}
@ -598,7 +601,7 @@ void YACReaderFlowGL::showPrevious()
viewRotateActive = 1;
}
}
}
void YACReaderFlowGL::showNext()
@ -778,7 +781,7 @@ void YACReaderFlowGL::populate(int n)
loaded = QVector<bool>(n,false);
//marks = QVector<bool>(n,false);
//worker->start();
}
@ -870,7 +873,7 @@ void YACReaderFlowGL::setCenter_Distance(int distance)
config.centerDistance = distance/100.0;
}
//sets the pushback amount
//sets the pushback amount
void YACReaderFlowGL::setZ_Distance(int distance)
{
startAnimationTimer();
@ -1025,6 +1028,11 @@ void YACReaderFlowGL::render()
//do nothing
}
void YACReaderFlowGL::setFlowRightToLeft(bool b)
{
flowRightToLeft = b;
}
//EVENTOS
void YACReaderFlowGL::wheelEvent(QWheelEvent * event)
{
@ -1045,7 +1053,7 @@ void YACReaderFlowGL::wheelEvent(QWheelEvent * event)
void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Left)
if((event->key() == Qt::Key_Left && !flowRightToLeft) || (event->key() == Qt::Key_Right && flowRightToLeft))
{
if(event->modifiers() == Qt::ControlModifier)
setCurrentIndex((currentSelected-10<0)?0:currentSelected-10);
@ -1055,7 +1063,7 @@ void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
return;
}
if(event->key() == Qt::Key_Right)
if((event->key() == Qt::Key_Right && !flowRightToLeft) || (event->key() == Qt::Key_Left && flowRightToLeft))
{
if(event->modifiers() == Qt::ControlModifier)
setCurrentIndex((currentSelected+10>=numObjects)?numObjects-1:currentSelected+10);
@ -1067,7 +1075,7 @@ void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
if(event->key() == Qt::Key_Up)
{
//emit selected(centerIndex());
//emit selected(centerIndex());
return;
}
@ -1098,7 +1106,7 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
if(posX >= 0.5)
if((posX >= 0.5 && !flowRightToLeft) || (posX <=-0.5 && flowRightToLeft))
{
//int index = currentSelected+1;
//while((cfImages[index].current.x-cfImages[index].width/(2.0*config.rotation)) < posX)
@ -1106,7 +1114,7 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
//setCurrentIndex(index-1);
showNext();
}
else if(posX <=-0.5)
else if((posX <=-0.5 && !flowRightToLeft) || (posX >= 0.5 && flowRightToLeft) )
showPrevious();
} else
QGLWidget::mousePressEvent(event);
@ -1199,7 +1207,7 @@ void YACReaderComicFlowGL::updateImageData()
}
}
// try to load only few images on the left and right side
// try to load only few images on the left and right side
// i.e. all visible ones plus some extra
int count=8;
switch(performance)
@ -1224,7 +1232,7 @@ void YACReaderComicFlowGL::updateImageData()
{
indexes[j*2+1] = center+j+1;
indexes[j*2+2] = center-j-1;
}
}
for(int c = 0; c < 2*count+1; c++)
{
int i = indexes[c];
@ -1332,7 +1340,7 @@ void YACReaderPageFlowGL::updateImageData()
}
}
// try to load only few images on the left and right side
// try to load only few images on the left and right side
// i.e. all visible ones plus some extra
int count=8;
switch(performance)
@ -1357,17 +1365,17 @@ void YACReaderPageFlowGL::updateImageData()
{
indexes[j*2+1] = center+j+1;
indexes[j*2+2] = center-j-1;
}
}
for(int c = 0; c < 2*count+1; c++)
{
int i = indexes[c];
if((i >= 0) && (i < numObjects))
if(rawImages.size()>0)
if(!loaded[i]&&imagesReady[i])//slide(i).isNull())
{
worker->generate(i, rawImages.at(i));
delete[] indexes;
return;
}
@ -1416,7 +1424,7 @@ QImage ImageLoaderGL::loadImage(const QString& fileName)
return image;
}
ImageLoaderGL::ImageLoaderGL(YACReaderFlowGL * flow):
ImageLoaderGL::ImageLoaderGL(YACReaderFlowGL * flow):
QThread(),flow(flow),restart(false), working(false), idx(-1)
{
@ -1433,7 +1441,7 @@ ImageLoaderGL::~ImageLoaderGL()
bool ImageLoaderGL::busy() const
{
return isRunning() ? working : false;
}
}
void ImageLoaderGL::generate(int index, const QString& fileName)
{
@ -1491,9 +1499,9 @@ void ImageLoaderGL::run()
}
}
QImage ImageLoaderGL::result()
{
return img;
QImage ImageLoaderGL::result()
{
return img;
}
//-----------------------------------------------------------------------------
@ -1526,7 +1534,7 @@ QImage ImageLoaderByteArrayGL::loadImage(const QByteArray& raw)
return image;
}
ImageLoaderByteArrayGL::ImageLoaderByteArrayGL(YACReaderFlowGL * flow):
ImageLoaderByteArrayGL::ImageLoaderByteArrayGL(YACReaderFlowGL * flow):
QThread(),flow(flow),restart(false), working(false), idx(-1)
{
@ -1543,7 +1551,7 @@ ImageLoaderByteArrayGL::~ImageLoaderByteArrayGL()
bool ImageLoaderByteArrayGL::busy() const
{
return isRunning() ? working : false;
}
}
void ImageLoaderByteArrayGL::generate(int index, const QByteArray& raw)
{
@ -1591,8 +1599,7 @@ void ImageLoaderByteArrayGL::run()
}
}
QImage ImageLoaderByteArrayGL::result()
{
return img;
QImage ImageLoaderByteArrayGL::result()
{
return img;
}

View File

@ -57,13 +57,13 @@ struct Preset{
float animationSpeedUp;
//sets the maximum speed of the animation
float animationStepMax;
//sets the distance of view
//sets the distance of view
float animationFadeOutDist;
//sets the rotation increasion
float preRotation;
//sets the light strenght on rotation
//sets the light strenght on rotation
float viewRotateLightStrenght;
//sets the speed of the rotation
//sets the speed of the rotation
float viewRotateAdd;
//sets the speed of reversing the rotation
float viewRotateSub;
@ -71,17 +71,17 @@ struct Preset{
float viewAngle;
/*** Position Configuration ***/
//the X Position of the Coverflow
//the X Position of the Coverflow
float cfX;
//the Y Position of the Coverflow
//the Y Position of the Coverflow
float cfY;
//the Z Position of the Coverflow
//the Z Position of the Coverflow
float cfZ;
//the X Rotation of the Coverflow
//the X Rotation of the Coverflow
float cfRX;
//the Y Rotation of the Coverflow
//the Y Rotation of the Coverflow
float cfRY;
//the Z Rotation of the Coverflow
//the Z Rotation of the Coverflow
float cfRZ;
//sets the rotation of each cover
float rotation;
@ -89,7 +89,7 @@ struct Preset{
float xDistance;
//sets the distance between the centered and the non centered covers
float centerDistance;
//sets the pushback amount
//sets the pushback amount
float zDistance;
//sets the elevation amount
float yDistance;
@ -122,7 +122,7 @@ protected:
void drawCover(const YACReader3DImage & image);
void udpatePerspective(int width, int height);
int updateCount;
WidgetLoader * loader;
int fontSize;
@ -143,16 +143,19 @@ protected:
QVector<YACReader3DImage> images;
bool hasBeenInitialized;
// sets flow direction right-to-left (manga mode)
bool flowRightToLeft;
Performance performance;
bool bUseVSync;
/*** Animation Settings ***/
Preset config;
//sets/returns the curent selected cover
//sets/returns the curent selected cover
int currentSelected;
//defines the position of the centered cover
//defines the position of the centered cover
YACReader3DVector centerPos;
/*** Style ***/
@ -172,7 +175,7 @@ protected:
void startAnimationTimer();
void stopAnimationTimer();
public:
@ -198,7 +201,7 @@ public:
void draw();
//updates the coverflow
void updatePositions();
//inserts a new item to the coverflow
//inserts a new item to the coverflow
//if item is set to a value > -1 it updates a already set value
//otherwise a new entry is set
void insert(const char *name, GLuint Tex, float x, float y,int item = -1);
@ -215,9 +218,9 @@ public:
public slots:
void setCF_RX(int value);
//the Y Rotation of the Coverflow
//the Y Rotation of the Coverflow
void setCF_RY(int value);
//the Z Rotation of the Coverflow
//the Z Rotation of the Coverflow
void setCF_RZ(int value);
//perspective
@ -228,7 +231,7 @@ public:
void setX_Distance(int distance);
//sets the distance between the centered and the non centered covers
void setCenter_Distance(int distance);
//sets the pushback amount
//sets the pushback amount
void setZ_Distance(int distance);
void setCF_Y(int value);
@ -248,6 +251,8 @@ public:
void useVSync(bool b);
void setFlowRightToLeft(bool b);
virtual void updateImageData() = 0;
void reset();
@ -336,7 +341,7 @@ protected:
private:
QMutex mutex;
QWaitCondition condition;
bool restart;
bool working;

View File

@ -1,6 +1,27 @@
#include "comic.h"
#include "pdf_comic.h"
#if defined USE_PDFIUM && !defined NO_PDF
int pdfRead(void* param,
unsigned long position,
unsigned char* pBuf,
unsigned long size) {
QFile *file = static_cast<QFile *>(param);
file->seek(position);
qint64 numBytesRead = file->read(reinterpret_cast<char *>(pBuf), size);
if(numBytesRead > 0)
{
return numBytesRead;
}
return 0;
}
PdfiumComic::PdfiumComic()
{
FPDF_InitLibrary();
@ -17,7 +38,19 @@ PdfiumComic::~PdfiumComic()
bool PdfiumComic::openComic(const QString & path)
{
doc = FPDF_LoadDocument(path.toLocal8Bit().constData(), NULL);
pdfFile.setFileName(path);
if(pdfFile.open(QIODevice::ReadOnly) == false)
{
qDebug() << "unable to open file : " << path;
return false;
}
fileAccess.m_FileLen = pdfFile.size();
fileAccess.m_GetBlock = pdfRead;
fileAccess.m_Param = &pdfFile;
doc = FPDF_LoadCustomDocument(&fileAccess, NULL);
if (doc)
{
return true;
@ -48,23 +81,31 @@ unsigned int PdfiumComic::numPages()
QImage PdfiumComic::getPage(const int page)
{
if (!doc)
{
return QImage();
}
QImage image;
FPDF_PAGE pdfpage;
FPDF_BITMAP bitmap;
pdfpage = FPDF_LoadPage(doc, page);
if (!pdfpage)
{
qDebug() << FPDF_GetLastError();
return QImage();
}
//TODO: make target DPI configurable
double width = (FPDF_GetPageWidth(pdfpage)/72)*150;
double height = (FPDF_GetPageHeight(pdfpage)/72)*150;
image = QImage(width, height, QImage::Format_ARGB32);// QImage::Format_RGBX8888);
if (image.isNull())
{
return image;
}
image.fill(0xFFFFFFFF);
bitmap = FPDFBitmap_CreateEx(image.width(), image.height(), FPDFBitmap_BGRA, image.scanLine(0), image.bytesPerLine());

View File

@ -3,6 +3,7 @@
#include <QObject>
#include <QImage>
#include <QFile>
#if defined Q_OS_MAC && defined USE_PDFKIT
class MacOSXPDFComic
@ -37,6 +38,8 @@ class PdfiumComic
private:
FPDF_LIBRARY_CONFIG config;
FPDF_DOCUMENT doc;
FPDF_FILEACCESS fileAccess;
QFile pdfFile;
};
#else
#include "poppler-qt5.h"

View File

@ -1,19 +1,17 @@
#ifndef __YACREADER_GLOBAL_H
#define __YACREADER_GLOBAL_H
#if QT_VERSION >= 0x050000
#include <QStandardPaths>
#else
#include <QDesktopServices>
#endif
#include <QStandardPaths>
#define VERSION "8.6.0"
#define VERSION "9.0.0"
#define USE_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW "OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW "BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define REMOTE_BROWSE_PERFORMANCE_WORKAROUND "REMOTE_BROWSE_PERFORMANCE_WORKAROUND"
#define NUM_DAYS_BETWEEN_VERSION_CHECKS "NUM_DAYS_BETWEEN_VERSION_CHECKS"
#define LAST_VERSION_CHECK "LAST_VERSION_CHECK"
@ -21,6 +19,8 @@
#define LIBRARIES "LIBRARIES"
#define MAX_LIBRARIES_WARNING_NUM 10
namespace YACReader
{
@ -63,11 +63,10 @@ namespace YACReader
YLight,
YDark
};
QString getSettingsPath();
QString colorToName(LabelColors colors);
QString labelColorToRGBString(LabelColors color);
}
#endif