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

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
stickler
Posts: 6
Joined: 2011-01-22T13:28:32-07:00
Authentication code: 8675308

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

Post 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!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
Post Reply