Changeset 11613 for ImageMagick/trunk
- Timestamp:
- 07/12/08 14:24:54 (3 months ago)
- Location:
- ImageMagick/trunk
- Files:
-
- 3 modified
-
magick/color.c (modified) (3 diffs)
-
magick/shear.c (modified) (14 diffs)
-
wand/mogrify.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ImageMagick/trunk/magick/color.c
r11443 r11613 642 642 break; 643 643 } 644 case OpacityChannel:645 { 646 color= pixel->opacity;644 case AlphaChannel: 645 { 646 color=QuantumRange-pixel->opacity; 647 647 break; 648 648 } … … 1322 1322 { 1323 1323 (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 1324 ConcatenateColorComponent(&color, OpacityChannel,SVGCompliance,tuple);1324 ConcatenateColorComponent(&color,AlphaChannel,SVGCompliance,tuple); 1325 1325 } 1326 1326 (void) ConcatenateMagickString(tuple,")",MaxTextExtent); … … 1599 1599 { 1600 1600 (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 1601 ConcatenateColorComponent(&pixel,OpacityChannel,X11Compliance, 1602 tuple); 1601 ConcatenateColorComponent(&pixel,OpacityChannel,X11Compliance,tuple); 1603 1602 } 1604 1603 (void) ConcatenateMagickString(tuple,")",MaxTextExtent); -
ImageMagick/trunk/magick/shear.c
r11601 r11613 47 47 */ 48 48 #include "magick/studio.h" 49 #include "magick/artifact.h" 49 50 #include "magick/blob-private.h" 50 51 #include "magick/cache-private.h" … … 580 581 off_t 581 582 i; 582 583 583 584 unsigned short 584 value; 585 585 value; 586 586 587 i=(off_t) radon_info->height*x+y; 587 if ((i < 0) || 588 (( i*sizeof(*radon_info->cells)) >= radon_info->length))588 if ((i < 0) || 589 ((MagickSizeType) (i*sizeof(*radon_info->cells)) >= radon_info->length)) 589 590 return(0); 590 591 if (radon_info->type != DiskCache) … … 606 607 607 608 i=(off_t) radon_info->height*x+y; 608 if ((i < 0) || 609 (( i*sizeof(*radon_info->cells)) >= radon_info->length))609 if ((i < 0) || 610 ((MagickSizeType) (i*sizeof(*radon_info->cells)) >= radon_info->length)) 610 611 return(0); 611 612 if (radon_info->type != DiskCache) … … 651 652 652 653 unsigned short 653 value;654 cell; 654 655 655 656 for (i=0; i < (long) step; i++) 656 657 { 657 for (y=0; y < (long) p->height; y++)658 for (y=0; y < (long) (p->height-i-1); y++) 658 659 { 659 value=GetRadonCell(p,x+i,y); 660 (void) SetRadonCell(q,x+2*i,y,value+GetRadonCell(p,x+i+step,y+i)); 661 (void) SetRadonCell(q,x+2*i+1,y,value+GetRadonCell(p,x+i+step,y+i+1)); 660 cell=GetRadonCell(p,x+i,y); 661 (void) SetRadonCell(q,x+2*i,y,cell+GetRadonCell(p,x+i+step,y+i)); 662 (void) SetRadonCell(q,x+2*i+1,y,cell+GetRadonCell(p,x+i+step,y+i+1)); 663 } 664 for ( ; y < (long) (p->height-i); y++) 665 { 666 cell=GetRadonCell(p,x+i,y); 667 (void) SetRadonCell(q,x+2*i,y,cell+GetRadonCell(p,x+i+step,y+i)); 668 (void) SetRadonCell(q,x+2*i+1,y,cell); 669 } 670 for ( ; y < (long) p->height; y++) 671 { 672 cell=GetRadonCell(p,x+i,y); 673 (void) SetRadonCell(q,x+2*i,y,cell); 674 (void) SetRadonCell(q,x+2*i+1,y,cell); 662 675 } 663 676 } … … 771 784 bit=0; 772 785 byte=0; 773 i= 0;786 i=(long) (image->columns+7)/8; 774 787 for (x=0; x < (long) image->columns; x++) 775 788 { 776 789 byte<<=1; 777 if ((p->red < threshold) || (p->green < threshold) || 778 (p->blue < threshold)) 790 if (((MagickRealType) p->red < threshold) || 791 ((MagickRealType) p->green < threshold) || 792 ((MagickRealType) p->blue < threshold)) 779 793 byte|=0x01; 780 794 bit++; 781 795 if (bit == 8) 782 796 { 783 (void) SetRadonCell(source_cells, i++,y,bits[byte]);797 (void) SetRadonCell(source_cells,--i,y,bits[byte]); 784 798 bit=0; 785 799 byte=0; … … 790 804 { 791 805 byte<<=(8-bit); 792 (void) SetRadonCell(source_cells, i++,y,bits[byte]);806 (void) SetRadonCell(source_cells,--i,y,bits[byte]); 793 807 } 794 808 } … … 821 835 bit=0; 822 836 byte=0; 823 i= (long) (image->columns+7)/8;837 i=0; 824 838 for (x=0; x < (long) image->columns; x++) 825 839 { 826 840 byte<<=1; 827 if ((p->red < threshold) || (p->green < threshold) || 828 (p->blue < threshold)) 841 if (((MagickRealType) p->red < threshold) || 842 ((MagickRealType) p->green < threshold) || 843 ((MagickRealType) p->blue < threshold)) 829 844 byte|=0x01; 830 845 bit++; 831 846 if (bit == 8) 832 847 { 833 (void) SetRadonCell(source_cells, --i,y,bits[byte]);848 (void) SetRadonCell(source_cells,i++,y,bits[byte]); 834 849 bit=0; 835 850 byte=0; … … 840 855 { 841 856 byte<<=(8-bit); 842 (void) SetRadonCell(source_cells, --i,y,bits[byte]);857 (void) SetRadonCell(source_cells,i++,y,bits[byte]); 843 858 } 844 859 } … … 850 865 } 851 866 867 static void GetImageBackgroundColor(Image *image,const long offset, 868 ExceptionInfo *exception) 869 { 870 long 871 y; 872 873 MagickPixelPacket 874 background; 875 876 MagickRealType 877 count; 878 879 ViewInfo 880 *image_view; 881 882 /* 883 Compute average background color. 884 */ 885 if (offset <= 0) 886 return; 887 GetMagickPixelPacket(image,&background); 888 count=0.0; 889 image_view=AcquireCacheView(image); 890 for (y=0; y < (long) image->rows; y++) 891 { 892 register const PixelPacket 893 *p; 894 895 register long 896 x; 897 898 if ((y >= offset) && (y < ((long) image->rows-offset))) 899 continue; 900 p=AcquireCacheViewPixels(image_view,0,y,image->columns,1,exception); 901 if (p == (const PixelPacket *) NULL) 902 continue; 903 for (x=0; x < (long) image->columns; x++) 904 { 905 if ((x >= offset) && (x < ((long) image->columns-offset))) 906 continue; 907 background.red+=QuantumScale*p->red; 908 background.green+=QuantumScale*p->green; 909 background.blue+=QuantumScale*p->blue; 910 background.opacity+=QuantumScale*p->opacity; 911 count++; 912 p++; 913 } 914 } 915 image_view=DestroyCacheView(image_view); 916 image->background_color.red=RoundToQuantum((MagickRealType) QuantumRange* 917 background.red/count); 918 image->background_color.green=RoundToQuantum((MagickRealType) QuantumRange* 919 background.green/count); 920 image->background_color.blue=RoundToQuantum((MagickRealType) QuantumRange* 921 background.blue/count); 922 image->background_color.opacity=RoundToQuantum((MagickRealType) QuantumRange* 923 background.opacity/count); 924 } 925 852 926 MagickExport Image *DeskewImage(const Image *image,const double threshold, 853 927 ExceptionInfo *exception) 854 928 { 929 const char 930 *artifact; 931 855 932 double 856 933 degrees, … … 858 935 859 936 Image 860 *deskew_image; 937 *clone_image, 938 *median_image, 939 *rotate_image; 861 940 862 941 long … … 865 944 MagickBooleanType 866 945 status; 946 947 RectangleInfo 948 geometry; 867 949 868 950 register long … … 904 986 Deskew image. 905 987 */ 906 degrees=RadiansToDegrees( atan((double) skew/width/8));988 degrees=RadiansToDegrees(-atan((double) skew/width/8)); 907 989 if (image->debug != MagickFalse) 908 990 (void) LogMagickEvent(TransformEvent,GetMagickModule()," Deskew angle: %g", 909 991 degrees); 910 deskew_image=RotateImage(image,degrees,exception); 911 if (image->fuzz != 0.0) 912 { 913 Image 914 *image; 915 916 RectangleInfo 917 geometry; 918 919 /* 920 Trim image. 921 */ 922 image=ReduceNoiseImage(deskew_image,0.0,exception); 923 if (image != (Image *) NULL) 924 { 925 geometry=GetImageBoundingBox(image,exception); 926 image=DestroyImage(image); 927 image=CropImage(deskew_image,&geometry,exception); 928 if (image != (Image *) NULL) 929 { 930 deskew_image=DestroyImage(deskew_image); 931 deskew_image=image; 932 } 933 } 934 } 935 return(deskew_image); 992 artifact=GetImageArtifact(image,"deskew:auto-crop"); 993 if (artifact == (const char *) NULL) 994 return(RotateImage(image,degrees,exception)); 995 /* 996 Auto-crop image. 997 */ 998 clone_image=CloneImage(image,0,0,MagickTrue,exception); 999 if (clone_image == (Image *) NULL) 1000 return((Image *) NULL); 1001 GetImageBackgroundColor(clone_image,atol(artifact),exception); 1002 rotate_image=RotateImage(clone_image,degrees,exception); 1003 clone_image=DestroyImage(clone_image); 1004 if (rotate_image == (Image *) NULL) 1005 return((Image *) NULL); 1006 median_image=MedianFilterImage(rotate_image,0.0,exception); 1007 rotate_image=DestroyImage(rotate_image); 1008 if (median_image == (Image *) NULL) 1009 return((Image *) NULL); 1010 geometry=GetImageBoundingBox(median_image,exception); 1011 median_image=DestroyImage(median_image); 1012 if (image->debug != MagickFalse) 1013 (void) LogMagickEvent(TransformEvent,GetMagickModule()," Deskew geometry: " 1014 "%lux%lu%+ld%+ld",geometry.width,geometry.height,geometry.x,geometry.y); 1015 return(CropImage(image,&geometry,exception)); 936 1016 } 937 1017 … … 1333 1413 status=MagickTrue; 1334 1414 image_view=AcquireCacheViewThreadSet(image); 1335 #pragma omp parallel for1415 // #pragma omp parallel for 1336 1416 for (y=0; y < (long) height; y++) 1337 1417 { … … 1527 1607 status=MagickTrue; 1528 1608 image_view=AcquireCacheViewThreadSet(image); 1529 #pragma omp parallel for1609 // #pragma omp parallel for 1530 1610 for (x=0; x < (long) width; x++) 1531 1611 { -
ImageMagick/trunk/wand/mogrify.c
r11577 r11613 870 870 */ 871 871 if (*option == '+') 872 threshold= QuantumRange/2.2;872 threshold=40.0*QuantumRange/100.0; 873 873 else 874 874 threshold=StringToDouble(argv[i+1],QuantumRange);
