I have the following given:
size_t ImageLdr::MyStreamHandler(const MagickLib::Image *image,const void *pixels, const size_t columns)
{
}
Now I want to call ReadStream in my code:
MagickLib::Image* img = ReadStream(&imageinfo,&ImageLdr::MyStreamHandler,&ex);
But the compiler tells me "can't take address of 'MagickNet::ImageLdr::MyStreamHandler' unless creating delegate instance".
And when I create a delegate:
public delegate size_t SH(const MagickLib::Image *image,const void *pixels, const size_t columns);
SH^ sh = gcnew SH(this, &ImageLdr::MyStreamHandler);
MagickLib::Image* img = ReadStream(sh);
Then it says: "cannot convert parameter 2 from 'MagickNet::SH ^' to 'MagickLib::StreamHandler'".
So how can I pass my method to this callback function?
Passing function pointer to ReadStream with Managed C++
Passing function pointer to ReadStream with Managed C++
Last edited by codymanix on 2009-02-13T14:10:57-07:00, edited 1 time in total.
Re: Passing function pointer to ReadStream with Managed C++
I got it working now, seems one cannot create function pointers from managed classes, so I use a native class now which I call from my managed class.
Not I have another problem. Some image formats like Microsoft Bitmap store the rows from bottom to top instead of top to bottom.
How can my code know that without without having to guess it from file extension?
Additionally Iam not sure how to convert the void*pixels argument into the format which I need. Is there a function like
convert_magickpixels_to_given_format(void*dst,void*src, "RGBA")?
Not I have another problem. Some image formats like Microsoft Bitmap store the rows from bottom to top instead of top to bottom.
How can my code know that without without having to guess it from file extension?
Additionally Iam not sure how to convert the void*pixels argument into the format which I need. Is there a function like
convert_magickpixels_to_given_format(void*dst,void*src, "RGBA")?
Re: Passing function pointer to ReadStream with Managed C++
The Image structure includes an orientation member. Check image->orientation. If its not reporting correctly let us know and we will add a patch to the Subversion trunk.Not I have another problem. Some image formats like Microsoft Bitmap store the rows from bottom to top instead of top to bottom.
Assume you ask for RGBA at depth 8, for this example, use an unsigned char pointer:Additionally Iam not sure how to convert the void*pixels argument into the format which I need. Is there a function like
convert_magickpixels_to_given_format(void*dst,void*src, "RGBA")?
Code: Select all
unsigned char *p;
p=(unsigned char *) pixels;
red=(*p++);
green=(*p++);
blue=(*p++);
alpha=(*p++);
Re: Passing function pointer to ReadStream with Managed C++
Thanks for reply!
the orientation of the image the StreamHAndler gets passed seem to be always zero, whether it's a bitmap or not.The Image structure includes an orientation member. Check image->orientation. If its not reporting correctly let us know and we will add a patch to the Subversion trunk.
Is the internal format of magick image pixels currently guaranteed to always to be in this format?Assume you ask for RGBA at depth 8, for this example, use an unsigned char pointer:Code: Select all
unsigned char *p; p=(unsigned char *) pixels; red=(*p++); green=(*p++); blue=(*p++); alpha=(*p++);
Re: Passing function pointer to ReadStream with Managed C++
If you use the streaming interface the pixels are in the format you specify. The default is CharPixel with a RGB map. In addition to streaming you can import / export pixels with ExportImagePixels() and ImportImagePixels() or you can use the pixel cache (e.g. GetAuthenticPixels()). If you use the MagickWand API, you can use pixel views to access the pixel cache in parallel.