/* * * Copyright (C) 2006-2011 Anders Brander , * * Anders Kvist and Klaus Post * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef RS_UTILS_H #define RS_UTILS_H #include #include #define GETVAL(adjustment) \ gtk_adjustment_get_value((GtkAdjustment *) adjustment) #define SETVAL(adjustment, value) \ gtk_adjustment_set_value((GtkAdjustment *) adjustment, value) /** * A version of atof() that isn't locale specific * @note This doesn't do any error checking! * @param str A NULL terminated string representing a number * @return The number represented by str or 0.0 if str is NULL */ extern gdouble rs_atof(const gchar *str); /** * A convenience function to convert an EXIF timestamp to a unix timestamp. * @note This will only work until 2038 unless glib fixes its GTime * @param str A NULL terminated string containing a timestamp in the format "YYYY:MM:DD HH:MM:SS" (EXIF 2.2 section 4.6.4) * @return A unix timestamp or -1 on error */ GTime rs_exiftime_to_unixtime(const gchar *str); /** * A convenience function to convert an unix timestamp to an EXIF timestamp. * @note This will only work until 2038 unless glib fixes its GTime * @param timestamp A unix timestamp * @return A string formatted as specified in EXIF 2.2 section 4.6.4 */ gchar * rs_unixtime_to_exiftime(GTime timestamp); /** * Constrains a box to fill a bounding box without changing aspect * @param target_width The width of the bounding box * @param target_height The height of the bounding box * @param width The input and output width * @param height The input and output height */ extern void rs_constrain_to_bounding_box(gint target_width, gint target_height, gint *width, gint *height); /** * Try to count the number of processor cores in a system. * @note This currently only works for systems with /proc/cpuinfo * @return The numver of cores or 1 if the system is unsupported */ extern gint rs_get_number_of_processor_cores(void); /** * Detect cpu features * @return A bitmask of @RSCpuFlags */ guint rs_detect_cpu_features(void); /** * Return a path to the current config directory for Rawstudio - this is the * .rawstudio direcotry in home * @return A path to an existing directory */ extern const gchar * rs_confdir_get(void); /** * Return a cache directory for filename * @param filename A complete path to a photo * @return A directory to hold the cache. This is guarenteed to exist */ extern gchar * rs_dotdir_get(const gchar *filename); /** * Normalize a RS_RECT, ie makes sure that x1 < x2 and y1