Page 1 of 1

How can I make this to work ?

Posted: 2011-04-25T11:41:16-07:00
by bibbou
Hey!

First of all I'am French, so sorry for my english!

I'am trying to run this program :

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main (int argc, char **argv){
  MagickWand *mw;
  DrawingWand *dw;
  PixelWand *cw;
  MagickWandGenesis ();
  mw = NewMagickWand ();
  dw = NewDrawingWand ();
  cw = NewPixelWand ();
  PixelSetColor (cw, "white");
  MagickNewImage (mw, 640, 480, cw);
  DrawSetStrokeOpacity (dw, 1);
  PixelSetColor (cw, "red");
  DrawSetStrokeColor (dw, cw);
  DrawLine (dw, 100, 100, 200, 200);
  DrawSetFillOpacity (dw, 0.0);
  DrawCircle (dw, 200, 200, 250, 250);
  MagickDrawImage (mw, dw);
  MagickWriteImage (mw, "image.png");
  cw = DestroyPixelWand (cw);
  mw = DestroyMagickWand (mw);
  dw = DestroyDrawingWand (dw);
  MagickWandTerminus();
  return EXIT_SUCCESS;
}
I use the makefile below :

Code: Select all

CPPFLAGS=-I/usr/local/include/ImageMagick
LDFLAGS=-L/usr/local/lib -lMagickWand
all: wand-test
wand-test: wand-test.c
	gcc -o wand-test $< $(CPPFLAGS) $(LDFLAGS)
clean:
	rm wand-test
And I enter this in my console :

Code: Select all

bok@ubuntu:~/Documents/LC4/testM$ make
gcc -o wand-test wand-test.c -I/usr/local/include/ImageMagick -L/usr/local/lib -lMagickWand
bok@ubuntu:~/Documents/LC4/testM$ ./wand-test 
bok@ubuntu:~/Documents/LC4/testM$ ls
makefile  makefile~  wand-test  wand-test.c  wand-test.c~
The problem is than nothing appears and no file is created !

Am I doing this wrong ?

Thanks in advance.

Re: How can I make this to work ?

Posted: 2011-04-25T20:23:51-07:00
by el_supremo
I can't see anything wrong with what you've done.
I compiled your program in Windows and it works just fine.

Pete

Re: How can I make this to work ?

Posted: 2011-04-26T00:26:29-07:00
by bibbou
:(

I'll try to help by adding some infos :

I'm running Ubuntu 10.10

To install i followed this : http://www.imagemagick.org/script/insta ... e.php#unix

And I installed [sudo apt-get install] libmagickwand-dev

Did i miss something?

Re: How can I make this to work ?

Posted: 2011-04-26T11:14:22-07:00
by bibbou
Running this :

Code: Select all

typedef struct{
  int ageMinimum;
  int nbTotal;
  int nbHommes;
  int nbFemmes;
} trancheAge;

typedef struct{
  int id;
  char* nom;
  trancheAge* donnees;  
} pays;

Code: Select all

void pyramideAges(pays p,int annee,int colonne){
  MagickWand *mw;
  DrawingWand *dw;
  PixelWand *cw;
  int i;
  double largeurMax,largeur;
  MagickWandGenesis();
  mw = NewMagickWand();
  dw = NewDrawingWand();
  cw = NewPixelWand();
  PixelSetColor(cw, "white");
  MagickNewImage(mw, 600, 600, cw);
  DrawSetStrokeOpacity(dw, 1);
  PixelSetColor(cw, "black");
  DrawSetStrokeColor(dw, cw);
  DrawAnnotation(dw,10.0,15.0,p.nom);
  DrawAnnotation(dw,10.0,30.0,itoa(annee));
  printf("%d",colonne);
  switch (colonne){
    case NBTOTAL :
      DrawAnnotation(dw,10.0,45.0,"Population Totale");
      break;
    case NBHOMMES :
      DrawAnnotation(dw,10.0,45.0,"Population Masculine");
      break;
    case NBFEMMES :
      DrawAnnotation(dw,10.0,45.0,"Population Feminine");
      break;
    default :
      break;
  }
  largeurMax = maxPop(p,NBTOTAL);
  for (i = 1; i<22; i++){
    largeur = ((double) p.donnees[i].nbTotal)*(500.0/(double)largeurMax);
    DrawRectangle(dw, 300.0-(largeur/2.0), 500.0 - 20.0*i, 300.0+(largeur/2.0), 520.0 - 20.0*i);
  }
  MagickDrawImage(mw, dw);
  MagickWriteImage(mw, "image.png");
  cw = DestroyPixelWand(cw);
  mw = DestroyMagickWand(mw);
  dw = DestroyDrawingWand(dw);
  MagickWandTerminus();
}
I got those :

Code: Select all

projet: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1521.
projet: no decode delegate for this image format `/tmp/magick-7f0QWUw4-00000001' @ error/constitute.c/ReadImage/532.
projet: Postscript delegate failed `/tmp/magick-36I0N0zi':  @ error/ps.c/ReadPSImage/806.
projet: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1521.
projet: no decode delegate for this image format `/tmp/magick-ItW5V7zM-00000001' @ error/constitute.c/ReadImage/532.
projet: Postscript delegate failed `/tmp/magick-BaREIE2Z':  @ error/ps.c/ReadPSImage/806.
projet: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1521.
projet: no decode delegate for this image format `/tmp/magick-hDRVxsGv-00000001' @ error/constitute.c/ReadImage/532.
projet: Postscript delegate failed `/tmp/magick-k2tRd9lI':  @ error/ps.c/ReadPSImage/806.
projet: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1521.
projet: no decode delegate for this image format `/tmp/magick-CzmZmEDf-00000001' @ error/constitute.c/ReadImage/532.
projet: Postscript delegate failed `/tmp/magick-ccvyGxFr':  @ error/ps.c/ReadPSImage/806.
projet: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1521.
projet: no decode delegate for this image format `/tmp/magick-rHtzTvw0-00000001' @ error/constitute.c/ReadImage/532.
projet: Postscript delegate failed `/tmp/magick-VJEKr9Qb':  @ error/ps.c/ReadPSImage/806.
projet: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1521.
projet: no decode delegate for this image format `/tmp/magick-xAjvAMoM-00000001' @ error/constitute.c/ReadImage/532.
projet: Postscript delegate failed `/tmp/magick-4cKP1mZW':  @ error/ps.c/ReadPSImage/806.
And trying display :

Code: Select all

bok@ubuntu:~/Téléchargements$ display logo.jpg 
Version: ImageMagick 6.6.9-6 2011-04-25 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP   

Usage: display [options ...] file [ [options ...] file ...]

Image Settings:
  -alpha option        on, activate, off, deactivate, set, opaque, copy
                       transparent, extract, background, or shape
  -antialias           remove pixel-aliasing
  -authenticate password
                       decipher image with this password
  -backdrop            display image centered on a backdrop
  -channel type        apply option to select image channels
  -colormap type       Shared or Private
  -colorspace type     alternate image colorspace
  -comment string      annotate image with comment
  -compress type       type of pixel compression when writing the image
  -define format:option
                       define one or more image format options
  -delay value         display the next image after pausing
  -density geometry    horizontal and vertical density of the image
  -depth value         image depth
  -display server      display image to this X server
  -dispose method      layer disposal method
  -dither method       apply error diffusion to image
  -endian type         endianness (MSB or LSB) of the image
  -filter type         use this filter when resizing an image
  -format string     output formatted image characteristics
  -geometry geometry   preferred size and location of the Image window
  -gravity type        horizontal and vertical backdrop placement
  -identify            identify the format and characteristics of the image
  -immutable           displayed image cannot be modified
  -interlace type      type of image interlacing scheme
  -interpolate method  pixel color interpolation method
  -label string        assign a label to an image
  -limit type value    pixel cache resource limit
  -loop iterations     loop images then exit
  -map type            display image using this Standard Colormap
  -monitor             monitor progress
  -page geometry       size and location of an image canvas
  -profile filename    add, delete, or apply an image profile
  -quality value       JPEG/MIFF/PNG compression level
  -quantize colorspace reduce colors in this colorspace
  -quiet               suppress all warning messages
  -regard-warnings     pay attention to warning messages
  -remote command      execute a command in an remote display process
  -repage geometry     size and location of an image canvas (operator)
  -respect-parentheses settings remain in effect until parenthesis boundary
  -sampling-factor geometry
                       horizontal and vertical sampling factor
  -seed value          seed a new sequence of pseudo-random numbers
  -set property value  set an image property
  -size geometry       width and height of image
  -texture filename    name of texture to tile onto the image background
  -transparent-color color
                       transparent color
  -treedepth value     color tree depth
  -update seconds      detect when image file is modified and redisplay
  -verbose             print detailed information about the image
  -visual type         display image using this visual type
  -virtual-pixel method
                       virtual pixel access method
  -window id           display image to background of this window
  -window-group id     exit program when this window id is destroyed
  -write filename      write image to a file

Image Operators:
  -auto-orient         automagically orient image
  -border geometry     surround image with a border of color
  -clip                clip along the first path from the 8BIM profile
  -clip-path id        clip along a named path from the 8BIM profile
  -colors value        preferred number of colors in the image
  -contrast            enhance or reduce the image contrast
  -crop geometry       preferred size and location of the cropped image
  -decipher filename   convert cipher pixels to plain pixels
  -deskew threshold    straighten an image
  -despeckle           reduce the speckles within an image
  -edge factor         apply a filter to detect edges in the image
  -enhance             apply a digital filter to enhance a noisy image
  -equalize            perform histogram equalization to an image
  -extract geometry    extract area from image
  -flip                flip image in the vertical direction
  -flop                flop image in the horizontal direction
  -frame geometry      surround image with an ornamental border
  -fuzz distance       colors within this distance are considered equal
  -gamma value         level of gamma correction
  -monochrome          transform image to black and white
  -negate              replace every pixel with its complementary color
  -normalize           transform image to span the full range of colors
  -raise value         lighten/darken image edges to create a 3-D effect
  -resample geometry   change the resolution of an image
  -resize geometry     resize the image
  -roll geometry       roll an image vertically or horizontally
  -rotate degrees      apply Paeth rotation to the image
  -sample geometry     scale image with pixel sampling
  -segment value       segment an image
  -sharpen geometry    sharpen the image
  -strip               strip image of all profiles and comments
  -threshold value     threshold the image
  -thumbnail geometry  create a thumbnail of the image
  -trim                trim image edges

Image Sequence Operators:
  -coalesce            merge a sequence of images
  -flatten             flatten a sequence of images

Miscellaneous Options:
  -debug events        display copious debugging information
  -help                print program options
  -list type           print a list of supported option arguments
  -log format          format of debugging information
  -version             print version information

In addition to those listed above, you can specify these standard X
resources as command line options:  -background, -bordercolor,
-borderwidth, -font, -foreground, -iconGeometry, -iconic, -mattecolor,
-name, -shared-memory, -usePixmap, or -title.

By default, the image format of `file' is determined by its magic
number.  To specify a particular image format, precede the filename
with an image format name and a colon (i.e. ps:image) or specify the
image type as the filename suffix (i.e. image.ps).  Specify 'file' as
'-' for standard input or output.

Buttons: 
  1    press to map or unmap the Command widget
  2    press and drag to magnify a region of an image
  3    press to load an image from a visual image directory
display: delegate library support not built-in `' (X11) @ error/display.c/DisplayImageCommand/1899.

Re: How can I make this to work ?

Posted: 2011-04-27T10:49:55-07:00
by bibbou
Fixed using this before install:

./configure --with-modules