Radial fix, PDF gradinet implementation

Fixed radial shading cone display
Started working on coons shading, it can convert pdfreader colors to graphics colors(rgb only) and drow similar (in math sense) shape, however size is still wrong, figuring out how to diplay shape with corect size and offset.
Todo:
 Other gradients
 Size and offset
 Alpha Channel
This commit is contained in:
danya
2021-04-03 17:40:56 +03:00
parent f7b3f95bcb
commit f6e2e91a4d
12 changed files with 206 additions and 18 deletions

View File

@ -15,4 +15,9 @@ CORE_ROOT_DIR = $$PWD/../../../../../core
include($$CORE_ROOT_DIR/Common/base.pri)
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
ADD_DEPENDENCY(PdfReader)
ADD_DEPENDENCY(HtmlRenderer)
core_linux:include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lkernel -lgraphics

View File

@ -4,7 +4,7 @@
#include "../../../../DesktopEditor/graphics/pro/Graphics.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QApplication a(argc, argv );
MainWindow w;
w.show();
return a.exec();

View File

@ -3,6 +3,9 @@
#include <QPixmap>
#include <iostream>
#include "../../../../DesktopEditor/graphics/pro/Graphics.h"
#include "../../../../DesktopEditor/fontengine/ApplicationFontsWorker.h"
#include "../../../../DesktopEditor/common/Directory.h"
#include "../../../../PdfReader/PdfReader.h"
std::vector<Point> drawCircle1(int n, double cx, double cy, double r) {
std::vector<Point> res;
@ -34,8 +37,10 @@ MainWindow::~MainWindow()
void GenerateImg(QImage &img, std::vector<Point> &points, Info &info) {
NSGraphics::IGraphicsRenderer* pRasterRenderer = NSGraphics::Create();
pRasterRenderer->SetFontManager(NULL);
NSFonts::IFontManager *fmp = NSFonts::NSFontManager::Create();
pRasterRenderer->SetFontManager(fmp);
int nRasterW = img.size().width();
int nRasterH = img.size().height();
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
@ -70,6 +75,7 @@ void GenerateImg(QImage &img, std::vector<Point> &points, Info &info) {
auto b = info.p;
LONG *c = a.data();
double *p = b.data();
pRasterRenderer->CommandDrawText(L"Test", 10, 10, 345, 345);
pRasterRenderer->put_BrushType(info.gradient_type);
pRasterRenderer->put_BrushGradientColors(c, p, info.n_colors);
pRasterRenderer->PathCommandStart();
@ -92,17 +98,33 @@ void GenerateImg(QImage &img, std::vector<Point> &points, Info &info) {
}
}
void MainWindow::on_RenderPic_clicked()
{
QImage pm(400, 400, QImage::Format_RGB888);
GenerateImg(pm, points, info);
CApplicationFontsWorker oWorker;
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
oWorker.m_bIsNeedThumbnails = false;
if (!NSDirectory::Exists(oWorker.m_sDirectory))
NSDirectory::CreateDirectory(oWorker.m_sDirectory);
NSFonts::IApplicationFonts* pFonts = oWorker.Check();
PdfReader::CPdfReader PDFREADER(pFonts);
PDFREADER.LoadFromFile(L"test.pdf");
int page = ui->lineEdit->text().toInt();
PDFREADER.ConvertToRaster(page + 1, L"testpdf.bmp", 1);
QImage pm("testpdf.bmp");
// QImage pm(400, 400, QImage::Format_RGB888);
// GenerateImg(pm, points, info);
//setColor2(pm, 0x0000FF);
//pm.invertPixels();
ui->lable_test->setPixmap(QPixmap::fromImage(pm)) ;
ui->lable_test->setScaledContents(true);
ui->lable_test->resize(pm.size());
pm.save("test.bmp");
// ui->lable_test->resize(pm.size());
//pm.save("test.bmp");
// pFonts->Release();
}
@ -590,3 +612,17 @@ void MainWindow::on_TrianglePoint3Y_sliderMoved(int position)
on_RenderPic_clicked();
}
}
void MainWindow::on_LeftButton_clicked()
{
int page = ui->lineEdit->text().toInt();
ui->lineEdit->setText(QString::number(page - 1));
on_RenderPic_clicked();
}
void MainWindow::on_RightButton_clicked()
{
int page = ui->lineEdit->text().toInt();
ui->lineEdit->setText(QString::number(page + 1));
on_RenderPic_clicked();
}

View File

@ -124,6 +124,10 @@ private slots:
void on_TrianglePoint3Y_sliderMoved(int position);
void on_LeftButton_clicked();
void on_RightButton_clicked();
private:
Ui::MainWindow *ui;
};

View File

@ -549,6 +549,58 @@
<string>XY triangle</string>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>770</x>
<y>320</y>
<width>54</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>PDF</string>
</property>
</widget>
<widget class="QPushButton" name="LeftButton">
<property name="geometry">
<rect>
<x>680</x>
<y>400</y>
<width>80</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Left</string>
</property>
</widget>
<widget class="QPushButton" name="RightButton">
<property name="geometry">
<rect>
<x>790</x>
<y>400</y>
<width>80</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Right</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>730</x>
<y>360</y>
<width>113</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>746</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">