Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: CTX image loading #143

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/ctx/ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
#ifdef CONFIG_FLOW3R_CTX_FLAVOUR_FULL
#endif

int mp_ctx_vfs_load_file (const char *path,
unsigned char **contents,
long *length,
long max_length);
#define CTX_LOAD_FILE mp_ctx_vfs_load_file

#define CTX_IMPLEMENTATION
#include "ctx.h"
20 changes: 9 additions & 11 deletions components/ctx/ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -5412,6 +5412,9 @@ static inline CtxList *ctx_list_find_custom (CtxList *list,
#define CTX_ENABLE_FLOAT 1
#endif

#ifndef CTX_LOAD_FILE
#define CTX_LOAD_FILE ___ctx_file_get_contents
#endif

/* enable cmykf which is cmyk intermediate format
*/
Expand Down Expand Up @@ -34464,14 +34467,6 @@ ___ctx_file_get_contents (const char *path,
return 0;
}

static int
__ctx_file_get_contents (const char *path,
unsigned char **contents,
long *length)
{
return ___ctx_file_get_contents (path, contents, length, 1024*1024*1024);
}

#if !__COSMOPOLITAN__
#include <limits.h>
#endif
Expand Down Expand Up @@ -53075,11 +53070,13 @@ ctx_texture_load (Ctx *ctx, const char *path, int *tw, int *th, char *reid)
int w, h, components;
unsigned char *pixels = NULL;

#if 0
if (path[0] == '/' || !strncmp (path, "file://", 7))
{
pixels = stbi_load (path + (path[0]=='/'?0:7), &w, &h, &components, 0);
}
else
#endif
{
unsigned char *data = NULL;
long length = 0;
Expand Down Expand Up @@ -54934,7 +54931,7 @@ ctx_get_contents2 (const char *uri,
}

if (!strncmp (uri, "file://", 7))
success = ___ctx_file_get_contents (uri + 7, contents, length, max_len);
success = CTX_LOAD_FILE (uri + 7, contents, length, max_len);
#ifdef ITK_HAVE_FS
else if (!strncmp (uri, "itk:", 4))
{
Expand Down Expand Up @@ -54973,7 +54970,7 @@ ctx_get_contents2 (const char *uri,
success = 0;
}
#else
success = ___ctx_file_get_contents (uri, contents, length, max_len);
success = CTX_LOAD_FILE (uri, contents, length, max_len);
#endif
}
ctx_free (temp_uri);
Expand All @@ -54989,7 +54986,7 @@ ctx_get_contents (const char *uri,
return ctx_get_contents2 (uri, contents, length, 1024*1024*1024);
}


#if 0

typedef struct CtxMagicEntry {
int is_text;
Expand Down Expand Up @@ -55255,6 +55252,7 @@ CtxMediaTypeClass ctx_media_type_class (const char *media_type)
}
return ret;
}
#endif

#else
int
Expand Down
1 change: 1 addition & 0 deletions components/ctx/ctx_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define CTX_TILED 0
#define CTX_BAREMETAL 1
#define CTX_ONE_FONT_ENGINE 1
#define CTX_GET_CONTENTS 1

#define CTX_MAX_SCANLINE_LENGTH 960
#define CTX_MAX_JOURNAL_SIZE (1024*512)
Expand Down
Loading
Loading