image processing
-
i downloaded a code snippet from this site...the code snippet was to convert an rgb image to grayscale... i was able to understand the snippet but there is a line that is bothering me ... would any one plz explain it... int offset=bitmapdata.stride-image.width*3; i tried it on an image and found out that it returns the same as int offset=image.width*3; and yeah if bitmapdata.stride returns the scan width and image.width also returns the scan width then how come bitmapdata.stride-image.width*3 be equal to image.width*3.... plz help and yeah tell what bitmapdata.stride actually does....
haseeb
-
i downloaded a code snippet from this site...the code snippet was to convert an rgb image to grayscale... i was able to understand the snippet but there is a line that is bothering me ... would any one plz explain it... int offset=bitmapdata.stride-image.width*3; i tried it on an image and found out that it returns the same as int offset=image.width*3; and yeah if bitmapdata.stride returns the scan width and image.width also returns the scan width then how come bitmapdata.stride-image.width*3 be equal to image.width*3.... plz help and yeah tell what bitmapdata.stride actually does....
haseeb
-
It is not the same! Stride is a scan width. If you have bitmap width 49 the bitmap.stride is 150 but your offset is 147. Of course if you use 24bpp colour format.
hello... sir... thanx for the reply... sir i still have a problem... for 49 width bitmap the scanwidth is 150... how come... it should be 147. how can it be 150? what is actually the offset... plz reply
haseeb
-
hello... sir... thanx for the reply... sir i still have a problem... for 49 width bitmap the scanwidth is 150... how come... it should be 147. how can it be 150? what is actually the offset... plz reply
haseeb
Sorry, my mistake, the scanwidth of 49 width (in pixles) picture is not a 150 but 148, but still is not a 147. All time we talk about 24bpp format, that means you have 1 byte per each component of RGB system. 3*49 is 147 but 147 is not a multiple of 4, 147 mod 4 is different than 0, the nearest number which is multiple of 4 is 148 (148 mod 4 = 0). I don't know exactly why, but is something with memory alocation.