To examine the treatment of RGB Planer Data, I tested as follows.
(1)
convert source.tif -depth 16 -interlace plane RGB:test1.raw
convert source.tif -depth 16 -interlace partition RGB:test2.raw
cat test2.{R,G,B} > test2_cat.raw
cmp test1.raw test2_cat.raw
--> test1.raw and test2_cat.raw are same. (No problem)
(2)
convert -depth 16 -size XxY -interlace plane test2_cat.raw -depth 16 -interlace partition RGB:test3.raw
cmp test2.R test3.R
--> test2.R and test3.R are same.
cmp test2.G test3.G
--> test2.G and test3.G are differ. (test3.G shifts behind 1 line.)
cmp test2.B test3.B
--> test2.B and test3.B are differ. (test3.B shifts behind 2 lines. and test3.B's last 2 lines are repeated.)
Is this bug of Coder rgb.c ?
Problem Planer Raw Image @ ver. 6.4.2 and 6.4.3
Re: Problem Planer Raw Image @ ver. 6.4.2 and 6.4.3
I'm sorry it made a mistake.
>(2)
>convert -depth 16 -size XxY -interlace plane test2_cat.raw -depth 16 -interlace partition RGB:test3.raw
test2_cat.raw -> RGB:test2_cat.raw
>(2)
>convert -depth 16 -size XxY -interlace plane test2_cat.raw -depth 16 -interlace partition RGB:test3.raw
test2_cat.raw -> RGB:test2_cat.raw
Re: Problem Planer Raw Image @ ver. 6.4.2 and 6.4.3
I find what is bug.
In ReadRGBImage, it enters the "for(y=0..." loop after the first line is read, and the next line is read in the loop.
And, the data of previous line is written the memory in the same loop.
In this action, the data of the last reading in the loop is never written to the memory, bat the data of the last reading is actuall error (count=0 at ReadBlob), because there is no data for reading.
For Planer data, the data of the last reading is not error. It reads the data of next Plane's 1st line. and reading data is never written.
this is patch for rgb.c at 6.4.2
In ReadRGBImage, it enters the "for(y=0..." loop after the first line is read, and the next line is read in the loop.
And, the data of previous line is written the memory in the same loop.
In this action, the data of the last reading in the loop is never written to the memory, bat the data of the last reading is actuall error (count=0 at ReadBlob), because there is no data for reading.
For Planer data, the data of the last reading is not error. It reads the data of next Plane's 1st line. and reading data is never written.
this is patch for rgb.c at 6.4.2
Code: Select all
*** rgb.c.orig 2008-09-19 11:35:18.000000000 +0900
--- rgb.c 2008-09-20 11:38:07.000000000 +0900
***************
*** 403,412 ****
image=DestroyImageList(image);
return((Image *) NULL);
}
}
- count=ReadBlob(image,length,pixels);
- if (count != (ssize_t) length)
- break;
for (y=0; y < (long) image->extract_info.height; y++)
{
q=GetImagePixels(canvas_image,0,0,canvas_image->columns,1);
--- 403,413 ----
image=DestroyImageList(image);
return((Image *) NULL);
}
+ length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
+ count=ReadBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
}
for (y=0; y < (long) image->extract_info.height; y++)
{
q=GetImagePixels(canvas_image,0,0,canvas_image->columns,1);
***************
*** 455,464 ****
image=DestroyImageList(image);
return((Image *) NULL);
}
}
- count=ReadBlob(image,length,pixels);
- if (count != (ssize_t) length)
- break;
for (y=0; y < (long) image->extract_info.height; y++)
{
q=GetImagePixels(canvas_image,0,0,canvas_image->columns,1);
--- 456,466 ----
image=DestroyImageList(image);
return((Image *) NULL);
}
+ length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
+ count=ReadBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
}
for (y=0; y < (long) image->extract_info.height; y++)
{
q=GetImagePixels(canvas_image,0,0,canvas_image->columns,1);
***************
*** 509,518 ****
image=DestroyImageList(image);
return((Image *) NULL);
}
}
- count=ReadBlob(image,length,pixels);
- if (count != (ssize_t) length)
- break;
for (y=0; y < (long) image->extract_info.height; y++)
{
q=GetImagePixels(canvas_image,0,0,canvas_image->columns,1);
--- 511,521 ----
image=DestroyImageList(image);
return((Image *) NULL);
}
+ length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
+ count=ReadBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
}
for (y=0; y < (long) image->extract_info.height; y++)
{
q=GetImagePixels(canvas_image,0,0,canvas_image->columns,1);
Re: Problem Planer Raw Image @ ver. 6.4.2 and 6.4.3
Thanks for the patch. We will get it into the next point release of ImageMagick, 6.4.3-7.
Re: Problem Planer Raw Image @ ver. 6.4.2 and 6.4.3
cmyk.c ycbcr.c 's Planer mode may have a same problem.