[winpr,rdtk] use png only if supported by winpr

rdtk compiles in bitmaps of fonts. if png format is supported by winpr,
prefer the png images, otherwise use bmp
This commit is contained in:
Armin Novak 2023-07-31 11:46:21 +02:00 committed by akallabeth
parent 1caa439a54
commit bd79d8f100
6 changed files with 2940 additions and 20 deletions

View File

@ -20,6 +20,7 @@
#include <errno.h>
#include <winpr/config.h>
#include <winpr/wtypes.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
@ -33,6 +34,12 @@
#include "rdtk_font.h"
#if defined(WINPR_WITH_PNG)
#define FILE_EXT "png"
#else
#define FILE_EXT "bmp"
#endif
static int rdtk_font_draw_glyph(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font,
rdtkGlyph* glyph)
{
@ -618,7 +625,8 @@ rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
if (!fontImageFile)
goto cleanup;
sprintf_s(fontImageFile, length + 8, "%s.png", fontBaseFile);
sprintf_s(fontImageFile, length + 8, "%s." FILE_EXT, fontBaseFile);
fontDescriptorFile = (char*)malloc(length + 8);
if (!fontDescriptorFile)
@ -750,7 +758,8 @@ int rdtk_font_engine_init(rdtkEngine* engine)
SSIZE_T descriptorSize;
const uint8_t* imageData = NULL;
const uint8_t* descriptorData = NULL;
imageSize = rdtk_get_embedded_resource_file("source_serif_pro_regular_12.png", &imageData);
imageSize =
rdtk_get_embedded_resource_file("source_serif_pro_regular_12." FILE_EXT, &imageData);
descriptorSize =
rdtk_get_embedded_resource_file("source_serif_pro_regular_12.xml", &descriptorData);

View File

@ -16,12 +16,20 @@
* limitations under the License.
*/
#include <winpr/config.h>
#include <rdtk/config.h>
#include "rdtk_resources.h"
#include "rdtk_nine_patch.h"
#if defined(WINPR_WITH_PNG)
#define FILE_EXT "png"
#else
#define FILE_EXT "bmp"
#endif
static int rdtk_image_copy_alpha_blend(uint8_t* pDstData, int nDstStep, int nXDst, int nYDst,
int nWidth, int nHeight, uint8_t* pSrcData, int nSrcStep,
int nXSrc, int nYSrc)
@ -373,7 +381,7 @@ int rdtk_nine_patch_engine_init(rdtkEngine* engine)
SSIZE_T size;
const uint8_t* data;
status = -1;
size = rdtk_get_embedded_resource_file("btn_default_normal.9.png", &data);
size = rdtk_get_embedded_resource_file("btn_default_normal.9." FILE_EXT, &data);
if (size > 0)
{
@ -401,7 +409,7 @@ int rdtk_nine_patch_engine_init(rdtkEngine* engine)
SSIZE_T size;
const uint8_t* data;
status = -1;
size = rdtk_get_embedded_resource_file("textfield_default.9.png", &data);
size = rdtk_get_embedded_resource_file("textfield_default.9." FILE_EXT, &data);
image = NULL;
if (size > 0)

File diff suppressed because it is too large Load Diff

View File

@ -71,8 +71,6 @@ rdtkSurface* rdtk_surface_new(rdtkEngine* engine, uint8_t* data, uint16_t width,
return NULL;
}
memset(surface->data, 0, surface->scanline * surface->height);
surface->owner = true;
}

View File

@ -23,6 +23,7 @@
#cmakedefine WINPR_HAVE_GETPWUID_R
#cmakedefine WINPR_HAVE_STRNDUP
#cmakedefine WINPR_HAVE_UNWIND_H
#cmakedefine WINPR_WITH_PNG
#cmakedefine WITH_EVENTFD_READ_WRITE

View File

@ -151,6 +151,8 @@ if (WITH_LODEPNG)
find_package(lodepng REQUIRED)
winpr_definition_add(-DWITH_LODEPNG)
set(WINPR_WITH_PNG ON CACHE BOOL "build cache")
winpr_include_directory_add(${lodepng_INCLUDE_DIRS})
winpr_library_add_private(${lodepng_LIBRARIES})
endif()