diff --git a/DesktopEditor/agg-2.4/include/test_grads/custom_gradients.h b/DesktopEditor/agg-2.4/include/test_grads/custom_gradients.h index 4924f1c9ad..50b17d52ad 100644 --- a/DesktopEditor/agg-2.4/include/test_grads/custom_gradients.h +++ b/DesktopEditor/agg-2.4/include/test_grads/custom_gradients.h @@ -2,6 +2,7 @@ #include #include #include "../../../graphics/AggPlusEnums.h" +#include "../../../graphics/structures.h" #ifndef M_1_PI #define M_1_PI 0.318309886183790671538 #endif @@ -81,15 +82,41 @@ namespace agg class calcRadial : public calcBase { public: - calcRadial(const NSStructures::GradientInfo &_gi) + calcRadial(const NSStructures::GradientInfo &_gi) : extend_to_inf_constant(10) { r0 = _gi.r0; r1 = _gi.r1; p0 = _gi.p0; p1 = _gi.p1; ginfo = _gi; + extend_back_coef = extend_front_coef = 0; + if (ginfo.continue_shading_b) + { + if (r0 < r1) + { + extend_back_coef = r0 / (r1 - r0); + } - + else + { + extend_back_coef = extend_to_inf_constant; + } + } + + if (ginfo.continue_shading_f) + { + if (r1 < r0) + { + extend_front_coef = r1 / (r0 - r1); + } + + else + { + extend_front_coef = extend_to_inf_constant; + } + } + + var_segment = 1 / (1 + extend_back_coef + extend_front_coef); } virtual float eval(float x, float y) override @@ -117,12 +144,13 @@ namespace agg { return NAN_FLOAT; } - float x1 = (-b + sqrtf(D)) / 2 / a; - float x2 = (-b - sqrtf(D)) / 2 / a; + float x2 = (-b + sqrtf(D)) / 2 / a; + float x1 = (-b - sqrtf(D)) / 2 / a; if (abs(a) < FLT_EPSILON) x1 = -c / b; + if (0 <= x1 && x1 <= 1) { return ginfo.shading.function.get_x_min() + @@ -133,18 +161,22 @@ namespace agg return ginfo.shading.function.get_x_min() + (ginfo.shading.function.get_x_max() - ginfo.shading.function.get_x_min()) * x2; } - if (ginfo.continue_shading_b) + + if (ginfo.continue_shading_b && + (0 >= x1 && x1 >= -extend_back_coef || + 0 >= x2 && x2 >= -extend_back_coef)) { - if (x1 <= 0 || x2 <= 0) - return ginfo.shading.function.get_x_min(); - + return ginfo.shading.function.get_x_min(); } - if (ginfo.continue_shading_f) + + + if (ginfo.continue_shading_f && + (1 <= x1 && x1 <= 1 + extend_front_coef || + 1 <= x2 && x2 <= 1 + extend_front_coef)) { - if (x1 >= 1 || x2 >= 1) - return ginfo.shading.function.get_x_max(); - + return ginfo.shading.function.get_x_max(); } + return NAN_FLOAT; } virtual ~calcRadial() {} @@ -153,6 +185,10 @@ namespace agg float r0, r1; NSStructures::Point p0,p1; NSStructures::GradientInfo ginfo; + + float extend_front_coef, extend_back_coef; + float var_segment; + float extend_to_inf_constant; }; /** @@ -218,6 +254,8 @@ namespace agg float cx, cy, factor; float inverseFactor; float invXsize, invYsize; + + }; /** diff --git a/PdfReader/Src/Graphics.cpp b/PdfReader/Src/Graphics.cpp index 1e11850ba7..f0c1d821d2 100644 --- a/PdfReader/Src/Graphics.cpp +++ b/PdfReader/Src/Graphics.cpp @@ -2813,7 +2813,7 @@ namespace PdfReader double dT1 = pShading->GetDomain1(); int nComponentsCount = pShading->GetColorSpace()->GetComponentsCount(); - if (0) // Графический тип рендера todo + if (true) // Графический тип рендера todo { double xmin, ymin, xmax, ymax; m_pGState->GetUserClipBBox(&xmin, &ymin, &xmax, &ymax); diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 6d43a2ca39..f597ed98f9 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -102,7 +102,7 @@ void GenerateImg(QImage &img, std::vector &points, Info &info) { void MainWindow::on_RenderPic_clicked() { - + /* CApplicationFontsWorker oWorker; oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache"; oWorker.m_bIsNeedThumbnails = false; @@ -114,9 +114,11 @@ void MainWindow::on_RenderPic_clicked() 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); + */ + + // 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));