sp-image.cpp revision 6fc0952fcafd54a656fdc8257ebb44bad58af163
1121N/A#define __SP_IMAGE_C__
1121N/A#ifdef HAVE_CONFIG_H
1121N/A//#include <gdk-pixbuf/gdk-pixbuf-io.h>
1121N/A#include "display/nr-arena-image.h"
1121N/A#include "attributes.h"
1121N/A#include "document.h"
1121N/A#include "sp-image.h"
1121N/A#include "sp-clippath.h"
1121N/A#include "libnr/nr-matrix-fns.h"
1121N/A#include "color-profile-fns.h"
1121N/A#include "color-profile.h"
1121N/A#ifdef DEBUG_LCMS
1121N/A#include "prefs-utils.h"
1121N/Astatic void sp_image_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
1121N/Astatic Inkscape::XML::Node *sp_image_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
1121N/Astatic void sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
1121N/Astatic NRArenaItem *sp_image_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
1121N/Astatic GdkPixbuf *sp_image_repr_read_image( time_t& modTime, gchar*& pixPath, const gchar *href, const gchar *absref, const gchar *base );
1121N/A#ifdef DEBUG_LCMS
1121N/Astatic GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& pixPath, GError **/*error*/ )
1121N/A#if defined(PNG_sRGB_SUPPORTED)
1121N/A#if defined(PNG_cHRM_SUPPORTED)
1121N/A#if defined(PNG_gAMA_SUPPORTED)
1121N/A double file_gamma = 0;
1121N/A#if defined(PNG_iCCP_SUPPORTED)
1121N/A int compression_type = 0;
387N/A// g_message("Found an iCCP chunk named [%s] with %d bytes and comp %d", name, proflen, compression_type);
1121N/Asp_image_get_type (void)
387N/A if (!image_type) {
1121N/A sizeof (SPImageClass),
1121N/A image_type = g_type_register_static (sp_item_get_type (), "SPImage", &image_info, (GTypeFlags)0);
1121N/A return image_type;
1121N/A case SP_ATTR_XLINK_HREF:
1121N/A case SP_ATTR_WIDTH:
1121N/A case SP_ATTR_HEIGHT:
1121N/A case SP_PROP_COLOR_PROFILE:
1121N/A#ifdef DEBUG_LCMS
if (pixbuf) {
#if ENABLE_LCMS
if ( px ) {
#ifdef DEBUG_LCMS
if ( prof ) {
switch ( profIntent ) {
intent, 0 );
if ( transf ) {
for ( int y = 0; y < imageheight; y++ ) {
#ifdef DEBUG_LCMS
#ifdef DEBUG_LCMS
DEBUG_MESSAGE( lcmsSeven, "in <image>'s sp_image_update. Profile type is named color. Can't transform." );
#ifdef DEBUG_LCMS
case SP_ASPECT_XMIN_YMIN:
case SP_ASPECT_XMID_YMIN:
case SP_ASPECT_XMAX_YMIN:
case SP_ASPECT_XMIN_YMID:
case SP_ASPECT_XMID_YMID:
case SP_ASPECT_XMAX_YMID:
case SP_ASPECT_XMIN_YMAX:
case SP_ASPECT_XMID_YMAX:
case SP_ASPECT_XMAX_YMAX:
image->trimwidth = static_cast<int>(static_cast<double>(imageheight) * image->width.computed / image->height.computed);
image->trimheight = static_cast<int>(static_cast<double>(imagewidth) * image->height.computed / image->width.computed);
sp_image_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
#if ENABLE_LCMS
return repr;
sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
pixskip = gdk_pixbuf_get_n_channels (image->pixbuf) * gdk_pixbuf_get_bits_per_sample (image->pixbuf) / 8;
t = s * tp;
t = ti * t;
t = s * tp;
t = ti * t;
sp_print_image_R8G8B8A8_N (ctx, px + image->trimx*pixskip + image->trimy*rs, image->trimwidth, image->trimheight, rs, &t, SP_OBJECT_STYLE (item));
static gchar *
char *href_desc;
href_desc) );
return ret;
static NRArenaItem *
pixskip = gdk_pixbuf_get_n_channels (image->pixbuf) * gdk_pixbuf_get_bits_per_sample (image->pixbuf) / 8;
rs);
rs);
nr_arena_image_set_geometry (NR_ARENA_IMAGE (ai), image->x.computed, image->y.computed, image->width.computed, image->height.computed);
nr_arena_image_set_geometry (NR_ARENA_IMAGE (ai), image->viewx, image->viewy, image->viewwidth, image->viewheight);
return ai;
GdkPixbuf *sp_image_repr_read_image( time_t& modTime, char*& pixPath, const gchar *href, const gchar *absref, const gchar *base )
modTime = 0;
if ( pixPath ) {
pixPath = 0;
if (fullname) {
g_warning ("<image xlink:href=\"%s\"> did not resolve to a valid image file (base dir is %s), now trying sodipodi:absref=\"%s\"", href, base, absref);
g_warning ("xlink:href did not resolve to a valid image file, now trying sodipodi:absref=\"%s\"", absref);
return pixbuf;
static GdkPixbuf *
return newbuf;
SPItemView *v;
pixskip = gdk_pixbuf_get_n_channels (image->pixbuf) * gdk_pixbuf_get_bits_per_sample (image->pixbuf) / 8;
rs);
rs);
return ret;
static GdkPixbuf *
while (*data) {
data_is_image = 1; // Illustrator produces embedded images without MIME type, so we assume it's image no matter what
while (*data) {
data++;
data++;
data++;
return pixbuf;
static GdkPixbuf *
gint j;
gint k;
gint l;
gint b;
while (eos == 0) {
len = 0;
btr++;
if (eos) {
ud[k] = 0;
ud[k] = 0;
ud[k] = 0;
btr++;
len++;
return pixbuf;
if ((image->height.computed < 1e-18) || (image->width.computed < 1e-18) || (image->clip_ref->getObject())) {
c->unref();
SPCurve *
return NULL;
if ( !val ) {