IM Core Enhancements
Posted: 2013-02-25T11:41:10-07:00
Hi,
Here are a few proposed tweaks to IM core based on my own internal modifications:
- CORE_png / pngvalid.c: interferes with the running of Boost test since it defines an int main(). Recommend removing 'pngvalid.c' from the default build. OpenCV has already removed the file from their build. Reference: http://stackoverflow.com/q/12165121/882436
- CORE_zlib / deflate.c: modify TOO_FAR macro based on logic in accordance with this: http://optipng.sourceforge.net/pngtech/too_far.html Since IM is an image library rather than a text library, the modification is a no-brainer IMO.
- CORE_magick / threshold.c, OrderedPosterizeImageChannel
The logic within this function requires an external XML file, which results in lower performance, conflicts with my static build and complicates my deployment. Recommend hard-coding the default threshold maps, while still allowing the use of the external XML file for custom-defined threshold maps. Here is the code I'm using starting at line 1459:
I'd imagine a simple "if token == hard_coded_map_1 then [x] else if token==hard_coded_map_2 then.....else parse_xml_file()" type operation would be appropriate. If you want to pursue this idea further and want me to submit some code, I'd be happy to do so.
Thanks in advance!
Here are a few proposed tweaks to IM core based on my own internal modifications:
- CORE_png / pngvalid.c: interferes with the running of Boost test since it defines an int main(). Recommend removing 'pngvalid.c' from the default build. OpenCV has already removed the file from their build. Reference: http://stackoverflow.com/q/12165121/882436
- CORE_zlib / deflate.c: modify TOO_FAR macro based on logic in accordance with this: http://optipng.sourceforge.net/pngtech/too_far.html Since IM is an image library rather than a text library, the modification is a no-brainer IMO.
- CORE_magick / threshold.c, OrderedPosterizeImageChannel
The logic within this function requires an external XML file, which results in lower performance, conflicts with my static build and complicates my deployment. Recommend hard-coding the default threshold maps, while still allowing the use of the external XML file for custom-defined threshold maps. Here is the code I'm using starting at line 1459:
Code: Select all
//map = GetThresholdMap(token, exception);
// TC
// hard code threshold map so we don't have to parse xml
map = (ThresholdMap *)AcquireMagickMemory(sizeof(ThresholdMap));
if ( map == (ThresholdMap *)NULL )
ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireThresholdMap");
map->map_id = ConstantString("threshold");
map->description = ConstantString("");
map->width = 1;
map->height = 1;
map->divisor = 2;
map->levels=(ssize_t *) AcquireQuantumMemory((size_t) map->width,map->height * sizeof(*map->levels));
if ( map->levels == (ssize_t *)NULL )
ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireThresholdMap");
map->levels[0] = 1;
// end tc
if ( map == (ThresholdMap *)NULL ) {
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"InvalidArgument","%s : '%s'","ordered-dither",threshold_map);
return(MagickFalse);
Thanks in advance!