Page 1 of 1

Accessing a single R,G or B pixel row in ReadStream callback

Posted: 2011-02-12T01:34:28-07:00
by stickler
Hi,
I am trying to stream a very large image .For this I use the ReadStream method and in the callback I write:-

Code: Select all

static size_t Callback( const Image *image,const void *pixels,
  const size_t columns)
{
  ExceptionInfo* exception;
  const PixelPacket *pp;
  if(numbers<image->rows)
  {
  pp=AcquireImagePixels(image,0,numbers,image->columns,1,exception);
  }
  numbers++;
  return(columns);
}
pp here i believe is the pointer to the whole structure(r/g and b).I need this to be copied to the CUDA device which is why i need the RG and B arrays separately ..Is there a way to do this?
Thanks a lot!

Re: Accessing a single R,G or B pixel row in ReadStream call

Posted: 2011-02-13T11:05:21-07:00
by magick
A majority of the image formats stream pixels (red, green, and blue) from left to right and top to bottom. Since the callback does not maintain state, you'll need to provide state yourself by perhaps allocating a red, green, and blue pixel buffer and filling them as the pixels are streamed. You can use global variables or local state by referencing image->client_data. See http://www.imagemagick.org/script/archi ... php#stream.