1) есть прога, которая с помощью ИмаджМаджика дергает и выводит яркости пикселов на стдаут:
#include <stdlib.h>
#include <stdio.h>
#include <magick/api.h>
int main(int argc,char **argv) {
ExceptionInfo
exception;
Image
*image;
ImageInfo
*image_info;
PixelPacket
*pixels;
ViewInfo
*vinfo;
// Initialize the image info structure and read an image.
InitializeMagick(*argv);
GetExceptionInfo(&exception);
image_info=CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info->filename,"image.gif");
image=ReadImage(image_info,&exception);
if (image == (Image *) NULL) {
// print out something to let us know we are missing the
// delegates.mgk or whatever if that is the problem instead of just
// saying the file can't be loaded later
fprintf(stderr, "readFileMagick: %s: %s\n",
exception.reason,exception.description);
// MagickError(exception.severity,exception.reason,exception.description);
// Get here if we can't decipher the file, let caller handle it.
return -1;
}
// Set the data size to accomodate this new image.
// width = image->columns;
// height = image->rows;
// This is the method for reading pixels that compiles and works,
// as opposed to GetImagePixels or GetOnePixel, which wouldn't compile.
vinfo = OpenCacheView(image);
pixels = GetCacheView(vinfo, 0,0,image->columns,image->rows);
if(!pixels) {
fprintf(stderr, "readFileMagick: unable to get pixel cache.\n");
return(-1);
}
int i,j;
for (j=0; j<image->rows; j++) {
for (i=0; i < image->columns; i++) {
// data ranges 0 to 256
// Swap data vertically, to match NM convention.
// file_data[j*width*3+i*3+0]=
printf("%d ",(int)pixels[i + image->columns*j].blue);
// file_data[j*image->columns*3+i*3+1]=
printf("%d ",(int)pixels[i + image->columns*j].green);
// file_data[j*image->columns*3+i*3+2]=
printf("%d \n",(int)pixels[i + image->columns*j].red);
}
}
// printf("%d \n",strlen(pixels));
CloseCacheView(vinfo);
DestroyImageInfo(image_info);
DestroyImage(image);
return(0);
}
компиляется
[vilfred@mobile100 Test]$ gcc `Magick-config --cflags --cppflags` test.c `Magick-config --ldflags --libs`
test.c: In function `main':
test.c:20: warning: implicit declaration of function `strcpy'
[vilfred@mobile100 Test]$
В чем же может быть проблема??
2) Таже самая прога но на XS:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <math.h>
#include <magick/api.h>
#include "ppport.h"
#define PackageName "MMM"
MODULE = MMM PACKAGE = MMM
PROTOTYPES: DISABLE
BOOT:
InitializeMagick(PackageName);
int
pixs(int l)
INIT:
ExceptionInfo
exception;
Image
*image;
ImageInfo
*info,
*image_info;
PixelPacket
*pixels;
ViewInfo
*vinfo;
CODE:
GetExceptionInfo(&exception);
printf("one\n");
strcpy(image_info->filename,"image.gif");
printf("one\n");
image=ReadImage(image_info,&exception);
printf("one\n");
RETVAL = l;
OUTPUT:
RETVAL
[vilfred@mobile100 MMM]$ perl x.pl
one
one
perl: constitute.c:2609: ReadImage: Assertion `image_info->signature == 0xabacadabUL' failed.
Aborted
[vilfred@mobile100 MMM]$
При поптыке втупую скопировать ReadImage метод из Magick.xs
вылетает на package_info... Вобщем, почему-то не XS не
работает, почему - я понять не могу :(
Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от vilfred
Ответ на:
комментарий
от dilmah
Ответ на:
комментарий
от dilmah

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от vilfred

Ответ на:
комментарий
от vilfred

Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Похожие темы
- Форум видимость переменных в разных функциях в С (2005)
- Форум icc ругается варнингом на сравнение volatile (2005)
- Форум Игрушки сигфолтятся (2005)
- Форум подскажите по сигфолту... (2008)
- Форум Альтовая мозилла сигфолтит (2002)
- Форум Странный варнинг (2006)
- Форум [C] ifdef strcpy (2010)
- Форум man 2 strcpy (2012)
- Форум dbx strcpy arguments (2006)
- Форум strcpy в kernel space (2007)