------------------------------------------------------------------------------
| 1789 | |
| 1790 | //------------------------------------------------------------------------------ |
| 1791 | void vtkPDFContextDevice2D::FillTexture() |
| 1792 | { |
| 1793 | assert(this->IsInTexturedFill); |
| 1794 | |
| 1795 | this->IsInTexturedFill = false; |
| 1796 | |
| 1797 | if (this->TextureBounds[0] == VTK_FLOAT_MAX || this->TextureBounds[1] == VTK_FLOAT_MIN || |
| 1798 | this->TextureBounds[2] == VTK_FLOAT_MAX || this->TextureBounds[3] == VTK_FLOAT_MIN) |
| 1799 | { // No geometry to texture: |
| 1800 | this->PopGraphicsState(); |
| 1801 | return; |
| 1802 | } |
| 1803 | |
| 1804 | // Use current path for clipping |
| 1805 | HPDF_Page_Clip(this->Impl->Page); |
| 1806 | HPDF_Page_EndPath(this->Impl->Page); |
| 1807 | |
| 1808 | // Prepare texture image |
| 1809 | vtkImageData* image = this->Brush->GetTexture(); |
| 1810 | assert(image); |
| 1811 | |
| 1812 | vtkImageData* rgb = this->PrepareImageData(image); |
| 1813 | if (!rgb) |
| 1814 | { |
| 1815 | return; |
| 1816 | } |
| 1817 | |
| 1818 | assert(rgb->GetScalarType() == VTK_UNSIGNED_CHAR); |
| 1819 | assert(rgb->GetNumberOfScalarComponents() == 3); |
| 1820 | |
| 1821 | int dims[3]; |
| 1822 | rgb->GetDimensions(dims); |
| 1823 | const HPDF_BYTE* buf = static_cast<HPDF_BYTE*>(rgb->GetScalarPointer()); |
| 1824 | |
| 1825 | HPDF_Image pdfImage = |
| 1826 | HPDF_LoadRawImageFromMem(this->Impl->Document, buf, dims[0], dims[1], HPDF_CS_DEVICE_RGB, 8); |
| 1827 | |
| 1828 | const bool isTiled = ((this->Brush->GetTextureProperties() & vtkBrush::Repeat) != 0); |
| 1829 | |
| 1830 | // tile across TextureBounds if repeating |
| 1831 | if (isTiled) |
| 1832 | { |
| 1833 | float x = this->TextureBounds[0]; |
| 1834 | while (x < this->TextureBounds[1]) |
| 1835 | { |
| 1836 | float y = this->TextureBounds[2]; |
| 1837 | while (y < this->TextureBounds[3]) |
| 1838 | { |
| 1839 | HPDF_Page_DrawImage(this->Impl->Page, pdfImage, x, y, dims[0], dims[1]); |
| 1840 | y += dims[1]; |
| 1841 | } |
| 1842 | x += dims[0]; |
| 1843 | } |
| 1844 | } |
| 1845 | else |
| 1846 | { // stretch across texture bounds if stretched |
| 1847 | HPDF_Page_DrawImage(this->Impl->Page, pdfImage, this->TextureBounds[0], this->TextureBounds[2], |
| 1848 | this->TextureBounds[1] - this->TextureBounds[0], |
no test coverage detected