Page 1 of 1
Image Stride
Posted: 2012-10-28T22:25:03-07:00
by tc33
I'm using the latest IM and the Magick++ interface. I need to provide an image's stride, along with the image width, to a function in a 3rd party library. However, I don't see how to retrieve/calculate an image's stride via the API. Any hints on how I can determine this info? I checked the docs and Google, but was unable to find a solution. Thanks!
Re: Image Stride
Posted: 2012-10-29T21:01:22-07:00
by fmw42
tc33 wrote:I'm using the latest IM and the Magick++ interface. I need to provide an image's stride, along with the image width, to a function in a 3rd party library. However, I don't see how to retrieve/calculate an image's stride via the API. Any hints on how I can determine this info? I checked the docs and Google, but was unable to find a solution. Thanks!
I know nothing about Magick++, but in reviewing the documentation, I see that info is at Accessing Image Attributes at
http://www.imagemagick.org/Magick++/tut ... torial.pdf. See link to Gentle Introduction at
http://www.imagemagick.org/script/magick++.php
Re: Image Stride
Posted: 2012-10-30T02:32:57-07:00
by tc33
Thanks. I re-reviewed the documentation, but was unable to determine which attribute is the 'stride'. What is the name of the stride attribute?
Re: Image Stride
Posted: 2012-10-30T10:40:03-07:00
by fmw42
tc33 wrote:Thanks. I re-reviewed the documentation, but was unable to determine which attribute is the 'stride'. What is the name of the stride attribute?
I expect you mean height
width is the horizontal number of pixels and height is the vertical number of pixels in an image.
Re: Image Stride
Posted: 2012-10-30T13:09:05-07:00
by tc33
Stride is different than height or width; I'm looking for the stride (or pitch?)
http://msdn.microsoft.com/en-us/library ... 73780.aspx
Right now i'm just using stride = columns * channel count, but don't know how to account for any other padding that may exist. I'm using the BMP2 format for this operation, so additional row padding might not even be in the spec; I'll have to dig a bit deeper to be sure. Thanks
Re: Image Stride
Posted: 2012-10-30T14:51:05-07:00
by fmw42
Sorry, I have never seen anything like that in IM. Is that for some special Windows video format? IM deals mostly with images not videos. Perhaps I misunderstand.
Any way, this is beyond my knowledge and this would be a question for the IM developers to answer.
Re: Image Stride
Posted: 2012-11-08T11:50:15-07:00
by tc33
I was able to dig this up in BMP.c, line 1583, specifically for the format I'm using (BMP2):
bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32);
So I'm going to assume that stride info is determined privately by each image type handler as needed, and it isn't exposed as a property in the magick image API.
Hope this helps someone else