Commit b7e824c3 authored by Claes Sjofors's avatar Claes Sjofors

Ge svg image support added

parent d5f0d143
......@@ -445,6 +445,7 @@ else
pwre_config_check_lib libusb LIBUSB lib libusb 1 "/usr/lib/libusb-1.0.so:/usr/lib/$hwpl-linux-$gnu/libusb-1.0.so"
pwre_config_check_lib powerlink POWERLINK lib powerlink 1 "$epl/build/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib powerlinkcn POWERLINKCN lib powerlinkcn 1 "$epl/buildcn/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib librsvg LIBRSVG lib librsvg 1 "/usr/lib/librsvg-2.so"
pwre_config_check_include mq MQ 0 "/usr/local/dmq/include/p_entry.h"
pwre_config_check_include wmq WMQ 1 "/opt/mqm/inc/cmqc.h"
......@@ -452,6 +453,7 @@ else
pwre_config_check_include nodave NODAVE 1 "/usr/include/nodave.h"
pwre_config_check_include powerlink EPL 1 "$epl/Include/Epl.h"
pwre_config_check_include powerlinkuser EPLU 0 "$epl/Examples/X86/Generic/powerlink_user_lib/EplCfg.h"
pwre_config_check_include rsvg RSVG 1 "/usr/include/librsvg-2/librsvg/rsvg.h:/usr/include/librsvg-2.0/librsvg/rsvg.h"
pwre_config_check_tool android ANDROID "/usr/local/android-sdk-linux/tools/android"
......
......@@ -614,7 +614,7 @@ localsubgraphs Ssab ssab_exe:*.pwsg
menu Local
{
localsubgraphs Subgraphs pwrp_pop:*.pwsg
localsubgraphs Images pwrp_pop:*.png,pwrp_pop:*.gif,pwrp_pop:*.jpg
localsubgraphs Images pwrp_pop:*.png,pwrp_pop:*.gif,pwrp_pop:*.jpg,pwrp_pop:*.svg
}
......
......@@ -47,6 +47,9 @@ using namespace std;
#include <math.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#if defined PWRE_CONF_RSVG
# include <rsvg.h>
#endif
#include "glow.h"
#include "glow_ctx.h"
......@@ -2900,11 +2903,16 @@ void GlowDrawGtk::image_flip_horizontal( glow_tImImage *image)
}
void GlowDrawGtk::image_scale( int width, int height, glow_tImImage orig_im, glow_tImImage *im,
glow_tImData *im_data,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask)
{
if ( width == gdk_pixbuf_get_width((GdkPixbuf *)*im) &&
height == gdk_pixbuf_get_height((GdkPixbuf *)*im))
return;
if ( width == 0 && height == 0) {
width = gdk_pixbuf_get_width((GdkPixbuf *)*im);
height = gdk_pixbuf_get_height((GdkPixbuf *)*im);
}
if ( !orig_im) {
// Scale from im
......@@ -2919,24 +2927,53 @@ void GlowDrawGtk::image_scale( int width, int height, glow_tImImage orig_im, glo
// Scale from orig_im
if ( *im)
gdk_pixbuf_unref( (GdkPixbuf *)*im);
*im = gdk_pixbuf_scale_simple( (GdkPixbuf *)orig_im, width, height, GDK_INTERP_NEAREST);
#if defined PWRE_CONF_RSVG
if (im_data && *im_data && *im) {
RsvgHandle *handle;
const char *imagefile;
handle = (RsvgHandle *) *im_data;
imagefile = rsvg_handle_get_base_uri( handle);
*im = rsvg_pixbuf_from_file_at_size(imagefile, width, height, NULL);
}
#else
{
#endif
else {
*im = gdk_pixbuf_scale_simple( (GdkPixbuf *)orig_im, width, height, GDK_INTERP_NEAREST);
}
}
}
int GlowDrawGtk::image_load( char *imagefile,
glow_tImImage *orig_im, glow_tImImage *im)
glow_tImImage *orig_im, glow_tImImage *im,
glow_tImData *im_data)
{
if ( im && *im)
gdk_pixbuf_unref( (GdkPixbuf *)*im);
if ( *orig_im)
gdk_pixbuf_unref( (GdkPixbuf *)*orig_im);
*orig_im = (glow_tImImage *) gdk_pixbuf_new_from_file( imagefile, 0);
if ( !*orig_im) {
if ( im)
*im = 0;
return 0;
#if defined PWRE_CONF_RSVG
if ( im_data &&
strcmp(strchr(imagefile, '.'), ".svg") == 0) {
RsvgHandle *handle;
handle = rsvg_handle_new_from_file( imagefile, NULL);
*im_data = (glow_tImImage *) handle;
*orig_im = (glow_tImImage *) rsvg_pixbuf_from_file( imagefile, NULL);
}
else {
#else
{
#endif
*orig_im = (glow_tImImage *) gdk_pixbuf_new_from_file( imagefile, 0);
if ( !*orig_im) {
if ( im)
*im = 0;
return 0;
}
}
if ( im) {
*im = (glow_tImImage *) gdk_pixbuf_copy( (GdkPixbuf *)*orig_im);
}
......
......@@ -207,9 +207,10 @@ class GlowDrawGtk : public GlowDraw {
void image_flip_vertical( glow_tImImage *image);
void image_flip_horizontal( glow_tImImage *image);
void image_scale( int width, int height, glow_tImImage orig_im, glow_tImImage *im,
glow_tImData *im_data,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask);
int image_load( char *imagefile,
glow_tImImage *orig_im, glow_tImImage *im);
glow_tImImage *orig_im, glow_tImImage *im, glow_tImData *im_data);
int image_render( int width, int height,
glow_tImImage orig_im, glow_tImImage *im,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask);
......
......@@ -2899,6 +2899,7 @@ void GlowDrawXLib::image_flip_horizontal( glow_tImImage *image)
}
void GlowDrawXLib::image_scale( int width, int height, glow_tImImage orig_im, glow_tImImage *im,
glow_tImData *im_data,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask)
{
#if 0
......@@ -2917,7 +2918,7 @@ void GlowDrawXLib::image_scale( int width, int height, glow_tImImage orig_im, gl
}
int GlowDrawXLib::image_load( char *imagefile,
glow_tImImage *orig_im, glow_tImImage *im)
glow_tImImage *orig_im, glow_tImImage *im, glow_tImData *im_data)
{
#if defined IMLIB
if ( *orig_im)
......
......@@ -232,9 +232,10 @@ class GlowDrawXLib : public GlowDraw {
void image_flip_vertical( glow_tImImage *image);
void image_flip_horizontal( glow_tImImage *image);
void image_scale( int width, int height, glow_tImImage orig_im, glow_tImImage *im,
glow_tImData *im_data,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask);
int image_load( char *imagefile,
glow_tImImage *orig_im, glow_tImImage *im);
glow_tImImage *orig_im, glow_tImImage *im, glow_tImData *im_data);
int image_render( int width, int height,
glow_tImImage orig_im, glow_tImImage *im,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask);
......
......@@ -156,9 +156,10 @@ class GlowDraw {
virtual void image_flip_vertical( glow_tImImage *image) {}
virtual void image_flip_horizontal( glow_tImImage *image) {}
virtual void image_scale( int width, int height, glow_tImImage orig_im, glow_tImImage *im,
glow_tImData *im_data,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask) {}
virtual int image_load( char *imagefile,
glow_tImImage *orig_im, glow_tImImage *im) {return 0;}
glow_tImImage *orig_im, glow_tImImage *im, glow_tImData *im_data) {return 0;}
virtual int image_render( int width, int height,
glow_tImImage orig_im, glow_tImImage *im,
glow_tPixmap *im_pixmap, glow_tPixmap *im_mask) {return 0;}
......
......@@ -67,7 +67,7 @@ GrowImage::GrowImage( GrowCtx *glow_ctx, const char *name, double x, double y,
ll(glow_ctx,x,y), ur(glow_ctx,x+1,y+1),
hot(0), pzero(glow_ctx), stored_pos(glow_ctx),
highlight(0), inverse(0), user_data(NULL),
dynamic(0), dynamicsize(0), image(0), original_image(0),
dynamic(0), dynamicsize(0), image_data(0), image(0), original_image(0),
pixmap(0), nav_pixmap(0), clip_mask(0), nav_clip_mask(0),
ctx(glow_ctx), display_level(display_lev),
color_tone(glow_eDrawTone_No), color_lightness(0),
......@@ -195,7 +195,7 @@ int GrowImage::insert_image( const char *imagefile)
date = info.st_ctime;
ctx->gdraw->image_load( filename, &original_image, &image);
ctx->gdraw->image_load( filename, &original_image, &image, &image_data);
if ( !original_image)
return 0;
......@@ -212,7 +212,7 @@ int GrowImage::insert_image( const char *imagefile)
set_image_color( image, NULL);
ctx->gdraw->image_scale( current_width, current_height,
original_image, &image, &pixmap, &clip_mask);
original_image, &image, &image_data, &pixmap, &clip_mask);
ctx->gdraw->image_render( current_width, current_height,
original_image, &image, &pixmap, &clip_mask);
......@@ -234,7 +234,7 @@ int GrowImage::update()
if ( date == info.st_ctime)
return 0;
ctx->gdraw->image_load( filename, &original_image, &image);
ctx->gdraw->image_load( filename, &original_image, &image, &image_data);
if ( !original_image)
return 0;
......@@ -242,7 +242,7 @@ int GrowImage::update()
set_image_color( image, NULL);
ctx->gdraw->image_scale( current_width, current_height,
original_image, &image, &pixmap, &clip_mask);
original_image, &image, &image_data, &pixmap, &clip_mask);
ctx->gdraw->image_render( current_width, current_height,
original_image, &image, &pixmap, &clip_mask);
......@@ -904,7 +904,7 @@ void GrowImage::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
if ( ur_x - ll_x != current_width || ur_y - ll_y != current_height) {
ctx->gdraw->image_scale( ur_x - ll_x, ur_y - ll_y, om,
&image, &pixmap, &clip_mask);
&image, &image_data, &pixmap, &clip_mask);
current_width = ctx->gdraw->image_get_width( image);
current_height = ctx->gdraw->image_get_height( image);
sts = 1;
......@@ -945,7 +945,7 @@ void GrowImage::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
if ( ctx->gdraw->image_get_width( image) != current_width ||
ctx->gdraw->image_get_height( image) != current_height) {
ctx->gdraw->image_scale( ur_x - ll_x, ur_y - ll_y, 0,
&image, &pixmap, &clip_mask);
&image, &image_data, &pixmap, &clip_mask);
current_width = ctx->gdraw->image_get_width( image);
current_height = ctx->gdraw->image_get_height( image);
}
......@@ -1747,7 +1747,7 @@ int grow_image_to_pixmap( GrowCtx *ctx, char *imagefile,
return 0;
}
ctx->gdraw->image_load( filename, image, 0);
ctx->gdraw->image_load( filename, image, 0, 0);
if ( !*image)
return 0;
......@@ -1757,7 +1757,7 @@ int grow_image_to_pixmap( GrowCtx *ctx, char *imagefile,
}
else {
ctx->gdraw->image_scale( width, height,
0, image, pixmap, 0);
0, image, 0, pixmap, 0);
}
ctx->gdraw->image_render( width, height,
0, image, pixmap, 0);
......
......@@ -287,6 +287,7 @@ class GrowImage : public GlowArrayElem {
int dynamicsize; //!< Size of dynamic code.
GlowTransform trf; //!< Transformation matrix of object.
glow_tImData imlib; //!< Pointer to imlib
glow_tImData image_data; //!< Information about an svg image.
glow_tImImage image; //!< The rendered and scaled image.
glow_tImImage original_image; //!< The original image.
glow_tPixmap pixmap; //!< Pixmap of the image.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment