for(int32_t i = 0; i < size; ++i)
{
- const double x = (float)i / (size - 1);
+ const double x = static_cast<float>(i) / (size - 1);
const double y = MIN(fct(x), 1.0f);
- values[i] = (float)y;
+ values[i] = static_cast<float>(y);
}
cmsToneCurve* result = cmsBuildTabulatedToneCurveFloat(NULL, size, values);
*profile_len = size;
}
cmsCloseProfile(profile);
- return (guchar *)data;
+ return static_cast<guchar *>(data);
}
else
{
heif_context_free(ctx);
heif_nclx_color_profile_free(nclxcp);
- return (guchar *)data;
+ return static_cast<guchar *>(data);
}
else
{
heif_context_free(ctx);
heif_nclx_color_profile_free(nclxcp);
- return (guchar *)profile;
+ return profile;
}
#else
guchar *heif_color_profile(FileData *UNUSED(fd), guint *UNUSED(profile_len))
#ifdef HAVE_LCMS2
profileID[16] = '\0';
cmsGetHeaderProfileID(profile, profileID);
- name = (gchar *) profileID;
+ name = reinterpret_cast<gchar *>(profileID);
#else
name = (gchar *) cmsTakeProductName(profile);
#endif
static void free_buffer(guchar *UNUSED(pixels), gpointer data)
{
- heif_image_release((const struct heif_image*)data);
+ heif_image_release(static_cast<const struct heif_image*>(data));
}
static gboolean image_loader_heif_load(gpointer loader, const guchar *buf, gsize count, GError **UNUSED(error))
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
struct heif_context* ctx;
struct heif_image* img;
struct heif_error error_code;
loader->area_prepared_cb = area_prepared_cb;
loader->data = data;
loader->page_num = 0;
- return (gpointer) loader;
+ return loader;
}
static void image_loader_heif_set_size(gpointer loader, int width, int height)
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
ld->requested_width = width;
ld->requested_height = height;
}
static GdkPixbuf* image_loader_heif_get_pixbuf(gpointer loader)
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
return ld->pixbuf;
}
static void image_loader_heif_set_page_num(gpointer loader, gint page_num)
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
ld->page_num = page_num;
}
static gint image_loader_heif_get_page_total(gpointer loader)
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
return ld->page_total;
}
static void image_loader_heif_abort(gpointer loader)
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
ld->abort = TRUE;
}
static void image_loader_heif_free(gpointer loader)
{
- ImageLoaderHEIF *ld = (ImageLoaderHEIF *) loader;
+ ImageLoaderHEIF *ld = static_cast<ImageLoaderHEIF *>(loader);
if (ld->pixbuf) g_object_unref(ld->pixbuf);
g_free(ld);
}
while (work)
{
- UnmapData *ud = (UnmapData *)work->data;
+ UnmapData *ud = static_cast<UnmapData *>(work->data);
if (ud->ptr == buf)
{
munmap(ud->map_data, ud->map_len);
}
map_len = st.st_size;
- map_data = (guchar *) mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0);
+ map_data = static_cast<guchar *>(mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0));
close(fd);
if (map_data == MAP_FAILED)
return NULL;
}
- ret = libraw_open_buffer(lrdt, (void *)map_data, map_len);
+ ret = libraw_open_buffer(lrdt, map_data, map_len);
if (ret == LIBRAW_SUCCESS)
{
ret = libraw_unpack_thumb(lrdt);
if (ret == LIBRAW_SUCCESS)
{
- il->mapped_file = (guchar *)lrdt->thumbnail.thumb;
+ il->mapped_file = reinterpret_cast<guchar *>(lrdt->thumbnail.thumb);
*data_len = lrdt->thumbnail.tlength;
ud = g_new(UnmapData, 1);
- ud->ptr =(guchar *)lrdt->thumbnail.thumb;
+ ud->ptr =reinterpret_cast<guchar *>(lrdt->thumbnail.thumb);
ud->map_data = map_data;
ud->map_len = lrdt->thumbnail.tlength;
ud->lrdt = lrdt;
libraw_unmap_list = g_list_prepend(libraw_unmap_list, ud);
- return (guchar *)lrdt->thumbnail.thumb;
+ return reinterpret_cast<guchar *>(lrdt->thumbnail.thumb);
}
}
static gboolean image_loader_pdf_load(gpointer loader, const guchar *buf, gsize count, GError **UNUSED(error))
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
GError *poppler_error = NULL;
PopplerPage *page;
PopplerDocument *document;
gboolean ret = FALSE;
gint page_total;
- document = poppler_document_new_from_data((gchar *)buf, count, NULL, &poppler_error);
+ document = poppler_document_new_from_data((gchar *)(buf), count, NULL, &poppler_error);
if (poppler_error)
{
loader->area_prepared_cb = area_prepared_cb;
loader->data = data;
loader->page_num = 0;
- return (gpointer) loader;
+ return loader;
}
static void image_loader_pdf_set_size(gpointer loader, int width, int height)
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
ld->requested_width = width;
ld->requested_height = height;
}
static GdkPixbuf* image_loader_pdf_get_pixbuf(gpointer loader)
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
return ld->pixbuf;
}
static void image_loader_pdf_set_page_num(gpointer loader, gint page_num)
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
ld->page_num = page_num;
}
static gint image_loader_pdf_get_page_total(gpointer loader)
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
return ld->page_total;
}
static void image_loader_pdf_abort(gpointer loader)
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
ld->abort = TRUE;
}
static void image_loader_pdf_free(gpointer loader)
{
- ImageLoaderPDF *ld = (ImageLoaderPDF *) loader;
+ ImageLoaderPDF *ld = static_cast<ImageLoaderPDF *>(loader);
if (ld->pixbuf) g_object_unref(ld->pixbuf);
g_free(ld);
}
static tsize_t
tiff_load_read (thandle_t handle, tdata_t buf, tsize_t size)
{
- ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+ ImageLoaderTiff *context = static_cast<ImageLoaderTiff *>(handle);
if (context->pos + size > context->used)
return 0;
static toff_t
tiff_load_seek (thandle_t handle, toff_t offset, int whence)
{
- ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+ ImageLoaderTiff *context = static_cast<ImageLoaderTiff *>(handle);
switch (whence)
{
static toff_t
tiff_load_size (thandle_t handle)
{
- ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+ ImageLoaderTiff *context = static_cast<ImageLoaderTiff *>(handle);
return context->used;
}
static int
tiff_load_map_file (thandle_t handle, tdata_t *buf, toff_t *size)
{
- ImageLoaderTiff *context = (ImageLoaderTiff *)handle;
+ ImageLoaderTiff *context = static_cast<ImageLoaderTiff *>(handle);
- *buf = (tdata_t *) context->buffer;
+ *buf = const_cast<guchar *>(context->buffer);
*size = context->used;
return 0;
static gboolean image_loader_tiff_load (gpointer loader, const guchar *buf, gsize count, GError **UNUSED(error))
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
TIFF *tiff;
guchar *pixels = NULL;
return FALSE;
}
- bytes = (size_t) height * rowstride;
- if (bytes / rowstride != (size_t) height)
+ bytes = static_cast<size_t>(height) * rowstride;
+ if (bytes / rowstride != static_cast<size_t>(height))
{ /* overflow */
DEBUG_1("Dimensions of TIFF image too large: height %d", height);
TIFFClose(tiff);
/* read by strip */
ptrdiff_t row;
const size_t line_bytes = width * sizeof(guint32);
- guchar *wrk_line = (guchar *)g_malloc(line_bytes);
+ guchar *wrk_line = static_cast<guchar *>(g_malloc(line_bytes));
for (row = 0; row < height; row += rowsperstrip)
{
}
/* Read the strip into an RGBA array */
- if (!TIFFReadRGBAStrip(tiff, row, (guint32 *)(pixels + row * rowstride))) {
+ if (!TIFFReadRGBAStrip(tiff, row, reinterpret_cast<guint32 *>(pixels + row * rowstride))) {
break;
}
/*
* Figure out the number of scanlines actually in this strip.
*/
- if (row + (int)rowsperstrip > height)
+ if (row + static_cast<int>(rowsperstrip) > height)
rows_to_write = height - row;
else
rows_to_write = rowsperstrip;
else
{
/* fallback, tiled tiff */
- if (!TIFFReadRGBAImageOriented (tiff, width, height, (guint32 *)pixels, ORIENTATION_TOPLEFT, 1))
+ if (!TIFFReadRGBAImageOriented (tiff, width, height, reinterpret_cast<guint32 *>(pixels), ORIENTATION_TOPLEFT, 1))
{
TIFFClose(tiff);
return FALSE;
loader->size_cb = size_cb;
loader->area_prepared_cb = area_prepared_cb;
loader->data = data;
- return (gpointer) loader;
+ return loader;
}
static void image_loader_tiff_set_size(gpointer loader, int width, int height)
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
lt->requested_width = width;
lt->requested_height = height;
}
static GdkPixbuf* image_loader_tiff_get_pixbuf(gpointer loader)
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
return lt->pixbuf;
}
static void image_loader_tiff_abort(gpointer loader)
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
lt->abort = TRUE;
}
static void image_loader_tiff_free(gpointer loader)
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
if (lt->pixbuf) g_object_unref(lt->pixbuf);
g_free(lt);
}
static void image_loader_tiff_set_page_num(gpointer loader, gint page_num)
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
lt->page_num = page_num;
}
static gint image_loader_tiff_get_page_total(gpointer loader)
{
- ImageLoaderTiff *lt = (ImageLoaderTiff *) loader;
+ ImageLoaderTiff *lt = static_cast<ImageLoaderTiff *>(loader);
return lt->page_total;
}
/**
* @file
* User API consists of the following namespaces:
- *
+ *
* @link image_methods Image:@endlink basic image information
*
* <b>Collection</b>: not implemented
- *
+ *
* @link exif_methods <exif-structure>:get_datum() @endlink get single exif parameter
*
*/
{
FileData **fd;
luaL_checktype(L, index, LUA_TUSERDATA);
- fd = (FileData **)luaL_checkudata(L, index, "Image");
+ fd = static_cast<FileData **>(luaL_checkudata(L, index, "Image"));
if (fd == NULL) luaL_typerror(L, index, "Image");
return *fd;
}
/**
* @brief Get exif structure of selected image
- * @param L
+ * @param L
* @returns An #ExifData data structure containing the entire exif data
- *
+ *
* To be used in conjunction with @link lua_exif_get_datum <exif-structure>:get_datum() @endlink
*/
static int lua_image_get_exif(lua_State *L)
fd = lua_check_image(L, 1);
exif = exif_read_fd(fd);
- exif_data = (ExifData **)lua_newuserdata(L, sizeof(ExifData *));
+ exif_data = static_cast<ExifData **>(lua_newuserdata(L, sizeof(ExifData *)));
luaL_getmetatable(L, "Exif");
lua_setmetatable(L, -2);
/**
* @brief Get full path of selected image
- * @param L
+ * @param L
* @returns char The full path of the file, including filename and extension
- *
- *
+ *
+ *
*/
static int lua_image_get_path(lua_State *L)
{
/**
* @brief Get full filename of selected image
- * @param L
+ * @param L
* @returns char The full filename including extension
- *
- *
+ *
+ *
*/
static int lua_image_get_name(lua_State *L)
{
/**
* @brief Get file extension of selected image
- * @param L
+ * @param L
* @returns char The file extension including preceding dot
- *
- *
+ *
+ *
*/
static int lua_image_get_extension(lua_State *L)
{
/**
* @brief Get file date of selected image
- * @param L
+ * @param L
* @returns time_t The file date in Unix timestamp format.
- *
+ *
* time_t - signed integer which represents the number of seconds since
* the start of the Unix epoch: midnight UTC of January 1, 1970
*/
/**
* @brief Get file size of selected image
- * @param L
+ * @param L
* @returns integer The file size in bytes
- *
- *
+ *
+ *
*/
static int lua_image_get_size(lua_State *L)
{
/**
* @brief Get marks of selected image
- * @param L
+ * @param L
* @returns unsigned integer Bit map of marks set
- *
+ *
* Bit 0 == Mark 1 etc.
- *
- *
+ *
+ *
*/
static int lua_image_get_marks(lua_State *L)
{
{
ExifData **exif;
luaL_checktype(L, index, LUA_TUSERDATA);
- exif = (ExifData **)luaL_checkudata(L, index, "Exif");
+ exif = static_cast<ExifData **>(luaL_checkudata(L, index, "Exif"));
if (exif == NULL) luaL_typerror(L, index, "Exif");
return *exif;
}
/**
* @brief Interface for EXIF data
- * @param L
+ * @param L
* @returns <i>return</i> A single exif tag extracted from a structure output by the @link lua_image_get_exif Image:get_exif() @endlink command
- *
+ *
* e.g. \n
* exif_structure = Image:get_exif(); \n
* DateTimeDigitized = exif_structure:get_datum("Exif.Photo.DateTimeDigitized");
* Exif.Photo.DateTimeOriginal = signed integer time_t \n
* Exif.Photo.DateTimeDigitized = signed integer time_t \n
* otherwise char
- *
+ *
*/
static int lua_exif_get_datum(lua_State *L)
{
exif = lua_check_exif(L, 1);
key = luaL_checkstring(L, 2);
- if (key == (gchar*)NULL || key[0] == '\0')
+ if (key == nullptr || key[0] == '\0')
{
lua_pushnil(L);
return 1;
* Call by e.g. \n
* @link lua_exif_get_datum <exif-structure>:get_datum() @endlink \n
* where <exif-structure> is the output of @link lua_image_get_exif Image:get_exif() @endlink
- *
+ *
* exif_structure = Image:get_exif(); \n
* DateTimeDigitized = exif_structure:get_datum("Exif.Photo.DateTimeDigitized");
*/
lua_setglobal(L, "Collection");
/* Current Image */
- image_data = (FileData **)lua_newuserdata(L, sizeof(FileData *));
+ image_data = static_cast<FileData **>(lua_newuserdata(L, sizeof(FileData *)));
luaL_getmetatable(L, "Image");
lua_setmetatable(L, -2);
lua_setglobal(L, "Image");