1df6105803c4c56c020a56301c7c9c4890fd4158mathog/** @file
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * @brief Metafile input - common routines
1df6105803c4c56c020a56301c7c9c4890fd4158mathog *//*
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * Authors:
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * David Mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog *
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * Copyright (C) 2013 Authors
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * Released under GNU GPL, read the file 'COPYING' for more information
1df6105803c4c56c020a56301c7c9c4890fd4158mathog */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#ifdef HAVE_CONFIG_H
1df6105803c4c56c020a56301c7c9c4890fd4158mathog# include "config.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#endif
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <cstring>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <fstream>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <glib.h>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <glibmm/miscutils.h>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "sp-root.h"
2238559b1acb6cb7b91188901478dd99e5e02518Martin Owens#include "display/curve.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "extension/internal/metafile-inout.h" // picks up PNG
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "extension/print.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "path-prefix.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "sp-gradient.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "sp-image.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "sp-linear-gradient.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "sp-pattern.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "sp-radial-gradient.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include "style.h"
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "document.h"
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "util/units.h"
5e657c265e2687328f5f9c7bf71a4c6b39bb3be9Liam P. White#include "ui/shape-editor.h"
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "sp-namedview.h"
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "document-undo.h"
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "inkscape.h"
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog#include "preferences.h"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathognamespace Inkscape {
1df6105803c4c56c020a56301c7c9c4890fd4158mathognamespace Extension {
1df6105803c4c56c020a56301c7c9c4890fd4158mathognamespace Internal {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogMetafile::~Metafile()
1df6105803c4c56c020a56301c7c9c4890fd4158mathog{
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog}
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog/** Construct a PNG in memory from an RGB from the EMF file
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogfrom:
1df6105803c4c56c020a56301c7c9c4890fd4158mathoghttp://www.lemoda.net/c/write-png/
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogwhich was based on:
1df6105803c4c56c020a56301c7c9c4890fd4158mathoghttp://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathoggcc -Wall -o testpng testpng.c -lpng
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogOriginally here, but moved up
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <png.h>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <stdio.h>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <stdlib.h>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog#include <stdint.h>
1df6105803c4c56c020a56301c7c9c4890fd4158mathog*/
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog/* Given "bitmap", this returns the pixel of bitmap at the point
1df6105803c4c56c020a56301c7c9c4890fd4158mathog ("x", "y"). */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogpixel_t * Metafile::pixel_at (bitmap_t * bitmap, int x, int y)
1df6105803c4c56c020a56301c7c9c4890fd4158mathog{
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return bitmap->pixels + bitmap->width * y + x;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog}
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog/* Write "bitmap" to a PNG file specified by "path"; returns 0 on
1df6105803c4c56c020a56301c7c9c4890fd4158mathog success, non-zero on error. */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogvoid
1df6105803c4c56c020a56301c7c9c4890fd4158mathogMetafile::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
1df6105803c4c56c020a56301c7c9c4890fd4158mathog{
1df6105803c4c56c020a56301c7c9c4890fd4158mathog PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog size_t nsize = p->size + length;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* allocate or grow buffer */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog else{ p->buffer = (char *) malloc(nsize); }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if(!p->buffer){ png_error(png_ptr, "Write Error"); }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* copy new bytes to end of buffer */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog memcpy(p->buffer + p->size, data, length);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog p->size += length;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog}
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathogvoid Metafile::toPNG(PMEMPNG accum, int width, int height, const char *px){
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap_t bmStore;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap_t *bitmap = &bmStore;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free().
1df6105803c4c56c020a56301c7c9c4890fd4158mathog accum->size=0;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap->pixels=(pixel_t *)px;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap->width = width;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap->height = height;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_structp png_ptr = NULL;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_infop info_ptr = NULL;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog size_t x, y;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_byte ** row_pointers = NULL;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* The following number is set by trial and error only. I cannot
1df6105803c4c56c020a56301c7c9c4890fd4158mathog see where it it is documented in the libpng manual.
1df6105803c4c56c020a56301c7c9c4890fd4158mathog */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog int pixel_size = 3;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog int depth = 8;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (png_ptr == NULL){
1df6105803c4c56c020a56301c7c9c4890fd4158mathog accum->buffer=NULL;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog info_ptr = png_create_info_struct (png_ptr);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (info_ptr == NULL){
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_destroy_write_struct (&png_ptr, &info_ptr);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog accum->buffer=NULL;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* Set up error handling. */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (setjmp (png_jmpbuf (png_ptr))) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_destroy_write_struct (&png_ptr, &info_ptr);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog accum->buffer=NULL;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* Set image attributes. */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_set_IHDR (
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_ptr,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog info_ptr,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap->width,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog bitmap->height,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog depth,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog PNG_COLOR_TYPE_RGB,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog PNG_INTERLACE_NONE,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog PNG_COMPRESSION_TYPE_DEFAULT,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog PNG_FILTER_TYPE_DEFAULT
1df6105803c4c56c020a56301c7c9c4890fd4158mathog );
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* Initialize rows of PNG. */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *));
1df6105803c4c56c020a56301c7c9c4890fd4158mathog for (y = 0; y < bitmap->height; ++y) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_byte *row =
1df6105803c4c56c020a56301c7c9c4890fd4158mathog (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog row_pointers[bitmap->height - y - 1] = row; // Row order in EMF is reversed.
1df6105803c4c56c020a56301c7c9c4890fd4158mathog for (x = 0; x < bitmap->width; ++x) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog pixel_t * pixel = pixel_at (bitmap, x, y);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB
1df6105803c4c56c020a56301c7c9c4890fd4158mathog *row++ = pixel->green;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog *row++ = pixel->blue;
1df6105803c4c56c020a56301c7c9c4890fd4158mathog }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* Write the image data to memory */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_set_rows (png_ptr, info_ptr, row_pointers);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_set_write_fn(png_ptr, accum, my_png_write_data, NULL);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog for (y = 0; y < bitmap->height; y++) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_free (png_ptr, row_pointers[y]);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog }
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_free (png_ptr, row_pointers);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog png_destroy_write_struct(&png_ptr, &info_ptr);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog}
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog/* If the viewBox is missing, set one
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog*/
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathogvoid Metafile::setViewBoxIfMissing(SPDocument *doc) {
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog if (doc && !doc->getRoot()->viewBox_set) {
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog bool saved = Inkscape::DocumentUndo::getUndoSensitive(doc);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog Inkscape::DocumentUndo::setUndoSensitive(doc, false);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog doc->ensureUpToDate();
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog // Set document unit
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog Inkscape::SVGOStringStream os;
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit;
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog os << doc_unit->abbr;
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog repr->setAttribute("inkscape:document-units", os.str().c_str());
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog // Set viewBox
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit)));
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog doc->ensureUpToDate();
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog // Scale and translate objects
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit);
5e657c265e2687328f5f9c7bf71a4c6b39bb3be9Liam P. White Inkscape::UI::ShapeEditor::blockSetItem(true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog double dh;
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog if(SP_ACTIVE_DOCUMENT){ // for file menu open or import, or paste from clipboard
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog dh = SP_ACTIVE_DOCUMENT->getHeight().value("px");
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog }
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog else { // for open via --file on command line
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog dh = doc->getHeight().value("px");
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog }
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog // These should not affect input, but they do, so set them to a neutral state
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog Inkscape::Preferences *prefs = Inkscape::Preferences::get();
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog bool transform_stroke = prefs->getBool("/options/transform/stroke", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog bool transform_pattern = prefs->getBool("/options/transform/pattern", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog bool transform_gradient = prefs->getBool("/options/transform/gradient", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/stroke", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/rectcorners", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/pattern", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/gradient", true);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
804ac6d80f744681705361c407a9ee11aaed685bmathog doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh), true);
5e657c265e2687328f5f9c7bf71a4c6b39bb3be9Liam P. White Inkscape::UI::ShapeEditor::blockSetItem(false);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog // restore options
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/stroke", transform_stroke);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/rectcorners", transform_rectcorners);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/pattern", transform_pattern);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog prefs->setBool("/options/transform/gradient", transform_gradient);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog Inkscape::DocumentUndo::setUndoSensitive(doc, saved);
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog }
3b70d4b4adefa3ff65931070bee74f26bab2f6f6mathog}
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog/**
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog \fn Convert EMF/WMF region combining ops to livarot region combining ops
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog \return combination operators in livarot enumeration, or -1 on no match
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog \param ops (int) combination operator (Inkscape)
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog*/
034d7ccaa6acbcd03e37974a2d164706862c32a2mathogint Metafile::combine_ops_to_livarot(const int op)
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog{
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog int ret = -1;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog switch(op) {
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog case U_RGN_AND:
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog ret = bool_op_inters;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog break;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog case U_RGN_OR:
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog ret = bool_op_union;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog break;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog case U_RGN_XOR:
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog ret = bool_op_symdiff;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog break;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog case U_RGN_DIFF:
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog ret = bool_op_diff;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog break;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog }
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog return(ret);
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog}
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog/* convert an EMF RGB(A) color to 0RGB
034d7ccaa6acbcd03e37974a2d164706862c32a2mathoginverse of gethexcolor() in emf-print.cpp
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog*/
034d7ccaa6acbcd03e37974a2d164706862c32a2mathoguint32_t Metafile::sethexcolor(U_COLORREF color){
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog uint32_t out;
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog out = (U_RGBAGetR(color) << 16) +
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog (U_RGBAGetG(color) << 8 ) +
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog (U_RGBAGetB(color) );
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog return(out);
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog}
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog/* Return the base64 encoded png which is shown for all bad images.
034d7ccaa6acbcd03e37974a2d164706862c32a2mathogCurrently a random 3x4 blotch.
034d7ccaa6acbcd03e37974a2d164706862c32a2mathogCaller must free.
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog*/
034d7ccaa6acbcd03e37974a2d164706862c32a2mathoggchar *Metafile::bad_image_png(void){
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog gchar *gstring = g_strdup("iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII=");
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog return(gstring);
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog}
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
034d7ccaa6acbcd03e37974a2d164706862c32a2mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog} // namespace Internal
1df6105803c4c56c020a56301c7c9c4890fd4158mathog} // namespace Extension
1df6105803c4c56c020a56301c7c9c4890fd4158mathog} // namespace Inkscape
1df6105803c4c56c020a56301c7c9c4890fd4158mathog
1df6105803c4c56c020a56301c7c9c4890fd4158mathog/*
1df6105803c4c56c020a56301c7c9c4890fd4158mathog Local Variables:
1df6105803c4c56c020a56301c7c9c4890fd4158mathog mode:c++
1df6105803c4c56c020a56301c7c9c4890fd4158mathog c-file-style:"stroustrup"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1df6105803c4c56c020a56301c7c9c4890fd4158mathog indent-tabs-mode:nil
1df6105803c4c56c020a56301c7c9c4890fd4158mathog fill-column:99
1df6105803c4c56c020a56301c7c9c4890fd4158mathog End:
1df6105803c4c56c020a56301c7c9c4890fd4158mathog*/
1df6105803c4c56c020a56301c7c9c4890fd4158mathog// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :