Page 1 of 1
[Magick++], JPEG Sampling Factor
Posted: 2010-09-08T05:20:59-07:00
by Im Jinho
Environment
- Visual Studio 2008
- Magick++
Hi, everyone.
I'm using work with Magick++.
I want to change sampling Factor of JPEG format from any image format for output file .
YUV420 : 2x2, 1x1, 1x1
YUV422 : 2x1, 1x1, 1x1
In case Color Space setting, there is colorSpace() Method.
like this, is there any method of Image class for this setting?
If not, how to change sampling Factor of image?
can I get some sample code to change sampling Factor of JPEG format image?
thank you for this question..
Re: [Magick++], JPEG Sampling Factor
Posted: 2010-09-08T05:41:47-07:00
by magick
Use defineValue() and set the magick to JPEG, key to sampling-factor, and the value to your desired sampling factors (e.g. 1x1,2x2,2x2).
Re: [Magick++], JPEG Sampling Factor
Posted: 2010-09-09T22:47:16-07:00
by Im Jinho
Hi.
First of all thanks for your help
I have been test as your advice, but I can't get any target that I want.
Here is sample code;
================================================================================
Code: Select all
if( m_outputFormat == "jpg" || m_outputFormat == "jpeg" ) {
ColorspaceType colorSpace;
std::string key = "sampling-factor";//"sampling_factor";
if( YUV422 ) {
//YUV422
magick = "JPEG";
samplingFactor = "2x1,1x1,1x1";
colorSpace = YCbCrColorspace;
}
else {
//YUV420
magick = "JPEG";
samplingFactor = "2x2,1x1,1x1";
colorSpace = YCbCrColorspace;
}
imageVector[i].magick( magick );
imageVector[i].defineValue( magick, key, samplingFactor );
defineValue -> modifyImage()
void Magick::Image::modifyImage()
{
Lock( &_imgRef->_mutexLock );
if ( _imgRef->_refCount == 1 )
{
// De-register image and return
_imgRef->id( -1 );
return;
}
}
================================================================================
value of _imgRef->_refCount in modifyImage() is 1.
So just return without following step processing, replaceImage().
What is a reason that cause this problem.
And how can I resolve this Image processing.
thanks!!
Re: [Magick++], JPEG Sampling Factor
Posted: 2010-09-13T00:51:18-07:00
by Im Jinho
I have resolved above problem, to set sampling factor of image option, with CloneString().
Code: Select all
imageVector[i].magick( magick );
MagickCore::ImageInfo *info = imageVector[i].options()->imageInfo();
MagickCore::CloneString(&info->sampling_factor, samplingFactor.c_str());
thanks.