Skip to content

Commit

Permalink
Merge pull request #368 from a740g/image-enhancements
Browse files Browse the repository at this point in the history
Image library enhancements
  • Loading branch information
a740g authored Sep 20, 2023
2 parents d6f69b2 + 66c3a77 commit b9ab80d
Show file tree
Hide file tree
Showing 26 changed files with 14,508 additions and 155 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ ifneq ($(filter y,$(DEP_SCREENIMAGE) $(DEP_IMAGE_CODEC)),)
CXXFLAGS += -DDEPENDENCY_IMAGE_CODEC
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))

LICENSE_IN_USE += dr_pcx stb_image
LICENSE_IN_USE += stb_image nanosvg dr_pcx qoi stb_image_write hqx mmpx sxbr
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
Expand Down
4 changes: 2 additions & 2 deletions internal/c/libqb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "rounding.h"
#include "thread.h"

using namespace std; // We should really get rid of this

int32 disableEvents = 0;

// Global console vvalues
Expand Down Expand Up @@ -4527,8 +4529,6 @@ int32 imgframe(uint8 *o, int32 x, int32 y, int32 bpp) {
return i;
}

void sub__freeimage(int32 i, int32 passed); // forward ref

int32 imgnew(int32 x, int32 y, int32 bpp) {
static int32 i, i2, i3;
static img_struct *im;
Expand Down
6 changes: 3 additions & 3 deletions internal/c/libqb.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void sub_shell4(qbs *, int32); //_DONTWAIT & _HIDE
int32 func__source();
int32 func_pos(int32 ignore);
void sub__printimage(int32 i);
double func_timer(double accuracy, int32 passed);
double func_timer(double accuracy, int32_t passed);
int32 func__newimage(int32 x, int32 y, int32 bpp, int32 passed);
void display();
void validatepage(int32);
Expand All @@ -25,12 +25,13 @@ int32 func__printwidth(qbs *, int32, int32);
void sub_cls(int32, uint32, int32);
void qbs_print(qbs *, int32);
int32 func__copyimage(int32 i, int32 mode, int32 passed);
void sub__freeimage(int32 i, int32 passed);
int32 func__dest();
int32 func__display();
void qbg_sub_view_print(int32, int32, int32);
qbs *qbs_new(int32, uint8);
qbs *qbs_new_txt(const char *);
qbs *qbs_new_txt_len(const char *, int32_t); // a740g: Added this here so that we don't have to declare it ourselves everywhere
qbs *qbs_new_txt_len(const char *, int32_t);
qbs *qbs_add(qbs *, qbs *);
qbs *qbs_set(qbs *, qbs *);
void qbg_sub_window(float, float, float, float, int32);
Expand Down Expand Up @@ -69,5 +70,4 @@ extern int32 no_control_characters2;
extern qbs *qbs_lcase(qbs *str);
extern qbs *qbs_ucase(qbs *str);

using namespace std;
#endif
36 changes: 11 additions & 25 deletions internal/c/libqb/include/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,21 @@
// \__\_\___/\___/ |_||_| |___| |___|_|_|_\__,_\__, \___| |____|_|_.__/_| \__,_|_| \_, |
// |___/ |__/
//
// QB64-PE Image Library
// Powered by stb_image (https://github.com/nothings/stb) & dr_pcx (https://github.com/mackron/dr_pcx)
//
// Copyright (c) 2022 Samuel Gomes
// https://github.com/a740g
// Powered by:
// stb_image & stb_image_write (https://github.com/nothings/stb)
// dr_pcx (https://github.com/mackron/dr_pcx)
// nanosvg (https://github.com/memononen/nanosvg)
// qoi (https://qoiformat.org)
// pixelscalers (https://github.com/janert/pixelscalers)
// mmpx (https://github.com/ITotalJustice/mmpx)
//
//-----------------------------------------------------------------------------------------------------

#pragma once

//-----------------------------------------------------------------------------------------------------
// HEADER FILES
//-----------------------------------------------------------------------------------------------------
#include <stdint.h>
#include <stdio.h>
//-----------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------
// MACROS
//-----------------------------------------------------------------------------------------------------
#if defined(IMAGE_DEBUG) && IMAGE_DEBUG > 0
# ifdef _MSC_VER
# define IMAGE_DEBUG_PRINT(_fmt_, ...) fprintf(stderr, "DEBUG: %s:%d:%s(): " _fmt_ "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
Expand All @@ -36,11 +31,11 @@
IMAGE_DEBUG_PRINT("Condition (%s) failed", #_exp_)
#else
# ifdef _MSC_VER
# define IMAGE_DEBUG_PRINT(_fmt_, ...) // Don't do anything in release builds
# define IMAGE_DEBUG_PRINT(_fmt_, ...) // Don't do anything in release builds
# else
# define IMAGE_DEBUG_PRINT(_fmt_, _args_...) // Don't do anything in release builds
# endif
# define IMAGE_DEBUG_CHECK(_exp_) // Don't do anything in release builds
# define IMAGE_DEBUG_CHECK(_exp_) // Don't do anything in release builds
#endif

// The byte ordering here are straight from libqb.cpp. So, if libqb.cpp is wrong, then we are wrong! ;)
Expand All @@ -51,17 +46,8 @@
#define IMAGE_GET_BGRA_BGR(c) ((uint32_t)(c) & 0xFFFFFFu)
#define IMAGE_MAKE_BGRA(r, g, b, a) \
((uint32_t)((uint8_t)(b) | ((uint32_t)((uint8_t)(g)) << 8) | ((uint32_t)((uint8_t)(r)) << 16) | ((uint32_t)((uint8_t)(a)) << 24)))
//-----------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------
// FORWARD DECLARATIONS
//-----------------------------------------------------------------------------------------------------
struct qbs;
//-----------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------
// FUNCTIONS
//-----------------------------------------------------------------------------------------------------
int32_t func__loadimage(qbs *fileName, int32_t bpp, qbs *requirements, int32_t passed);
//-----------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------
int32_t func__loadimage(qbs *qbsFileName, int32_t bpp, qbs *qbsRequirements, int32_t passed);
void sub__saveimage(qbs *qbsFileName, int32_t imageHandle, qbs *qbsRequirements, int32_t passed);
Loading

0 comments on commit b9ab80d

Please sign in to comment.