Imported Upstream version 0.13.2+dsfg1
This commit is contained in:
commit
fb3990e9e5
2036 changed files with 287360 additions and 0 deletions
63
libobs/graphics/graphics-magick.c
Normal file
63
libobs/graphics/graphics-magick.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#include "graphics.h"
|
||||
|
||||
#define MAGICKCORE_QUANTUM_DEPTH 16
|
||||
#define MAGICKCORE_HDRI_ENABLE 0
|
||||
#include <magick/MagickCore.h>
|
||||
|
||||
void gs_init_image_deps()
|
||||
{
|
||||
MagickCoreGenesis(NULL, MagickTrue);
|
||||
}
|
||||
|
||||
void gs_free_image_deps()
|
||||
{
|
||||
MagickCoreTerminus();
|
||||
}
|
||||
|
||||
uint8_t *gs_create_texture_file_data(const char *file,
|
||||
enum gs_color_format *format,
|
||||
uint32_t *cx_out, uint32_t *cy_out)
|
||||
{
|
||||
uint8_t *data = NULL;
|
||||
ImageInfo *info;
|
||||
ExceptionInfo *exception;
|
||||
Image *image;
|
||||
|
||||
if (!file || !*file)
|
||||
return NULL;
|
||||
|
||||
info = CloneImageInfo(NULL);
|
||||
exception = AcquireExceptionInfo();
|
||||
|
||||
strcpy(info->filename, file);
|
||||
image = ReadImage(info, exception);
|
||||
if (image) {
|
||||
size_t cx = image->magick_columns;
|
||||
size_t cy = image->magick_rows;
|
||||
data = bmalloc(cx * cy * 4);
|
||||
|
||||
ExportImagePixels(image, 0, 0, cx, cy, "BGRA", CharPixel,
|
||||
data, exception);
|
||||
if (exception->severity != UndefinedException) {
|
||||
blog(LOG_WARNING, "magickcore warning/error getting "
|
||||
"pixels from file '%s': %s", file,
|
||||
exception->reason);
|
||||
bfree(data);
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
*format = GS_BGRA;
|
||||
*cx_out = (uint32_t)cx;
|
||||
*cy_out = (uint32_t)cy;
|
||||
DestroyImage(image);
|
||||
|
||||
} else if (exception->severity != UndefinedException) {
|
||||
blog(LOG_WARNING, "magickcore warning/error reading file "
|
||||
"'%s': %s", file, exception->reason);
|
||||
}
|
||||
|
||||
DestroyImageInfo(info);
|
||||
DestroyExceptionInfo(exception);
|
||||
|
||||
return data;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue