Creating an image with an unpredictable number of rows

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
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Creating an image with an unpredictable number of rows

Post by rmagick »

I'd like to create an image a row at a time, where I don't know up front how many rows there will be. I've got code that uses AllocateImage to create a 0x0 image. I then set the number of columns. Then I build the image a row at a time, first incrementing the number of rows in the image by 1 and then calling SetImagePixels/SyncImagePixels to create the row.

This works, but, in the IM source code all the uses of SetImagePixels establish the total number of rows in the image before calling SetImagePixels. I'm concerned that I'm breaking an implicit rule. Is this an acceptable use of the SetImagePixels? If not, what is the correct way to do this?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Use SetImageExtent() to dynamically extend an image.
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Post by rmagick »

Thanks for the info!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

You can see its effect from the command line -extent operator, as shown in IM examples.
http://www.cit.gu.edu.au/~anthony/graph ... op/#extent
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Post by rmagick »

Thanks, Anthony. That example helps.
Post Reply