Changeset 4748 for extensions/pLoader
- Timestamp:
- Jan 26, 2010, 8:20:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm
r4718 r4748 562 562 $self->imagelist->SetCurrentImage(-1); 563 563 564 $self->imagelist->RescaleCallback(565 sub { $self->RescaleImage(@_) }566 );567 568 564 $self->imagelist->ResizeCallback( 569 565 sub { $self->ResizeImage(@_) } … … 616 612 version => $self->version, 617 613 imagelist_version => $self->imagelist_version, 618 RescaleCallback => sub { $self->RescaleImage(@_) },619 614 ResizeCallback => sub { $self->ResizeImage(@_) }, 620 615 watermark_text => $self->user_defined_properties->{watermark_text}||gettext("my watermark"), … … 801 796 802 797 803 sub RescaleImage { 804 my ( $self, $image_file, $image_file_out, $type, $ratio, $width, $height, $quality ) = @_; 798 799 sub ResizeImage { 800 my ( $self, $image_file, $image_file_out, $type, $width, $height, $quality ) = @_; 805 801 806 802 … … 810 806 0 811 807 ); 812 808 813 809 my $w; 814 810 my $h; … … 817 813 my $img_h = $image->GetHeight; 818 814 819 # use a ratio ( 25% default ) if defined820 # default ratio is used for preview.821 if($ratio){822 $w = $ratio*$img_w/100 ;823 $h = $ratio*$img_h/100 ;824 }825 # use specified width and height826 else{827 815 # portrait 828 816 if( $img_w < $img_h ){ … … 837 825 ($w*$img_h)/$img_w 838 826 ); 839 } 827 828 840 829 841 830 $image->Rescale( … … 844 833 wxIMAGE_QUALITY_HIGH 845 834 ); 846 847 $quality ||= 90; 848 849 $image->SetOption( 850 "quality", 851 $quality 852 ); 853 854 if(!$image->SaveFile( 855 $image_file_out, 856 $self->GetWxBitmapType($type), 857 )){ 858 Wx::LogMessage( 859 gettext("An error has occured. Can not save file %s"), 860 $image_file_out, 861 ) 862 }; 863 } 864 865 sub ResizeImage { 866 my ( $self, $image_file, $image_file_out, $type, $width, $height, $quality ) = @_; 867 868 869 my $image = Wx::Image->new( 870 $image_file, 871 $self->GetWxBitmapType($type), 872 0 873 ); 874 875 my $w; 876 my $h; 877 878 my $img_w = $image->GetWidth; 879 my $img_h = $image->GetHeight; 880 881 # portrait 882 if( $img_w < $img_h ){ 883 $w = $height; 884 } 885 else{ 886 $w = $width; 887 } 888 # to respect aspect ratio 889 $h = sprintf( 890 "%.0f", 891 ($w*$img_h)/$img_w 892 ); 893 894 895 896 $image->Rescale( 897 $w, 898 $h, 899 wxIMAGE_QUALITY_HIGH 900 ); 901 902 $image->Resize( 903 [ $width, $height ], [ 0, 20], 904 ); 835 836 #$image->Resize( 837 # [ $width, $height ], [ 0, 20], 838 #); 905 839 906 840 $quality ||= 90;
Note: See TracChangeset
for help on using the changeset viewer.