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..
[Magick++], JPEG Sampling Factor
Re: [Magick++], JPEG Sampling Factor
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
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;
================================================================================
================================================================================
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!!
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
I have resolved above problem, to set sampling factor of image option, with CloneString().
thanks.
Code: Select all
imageVector[i].magick( magick );
MagickCore::ImageInfo *info = imageVector[i].options()->imageInfo();
MagickCore::CloneString(&info->sampling_factor, samplingFactor.c_str());