Why not store only the original and, if desired, resize when loading it?

Op 7-sep-2007, om 9:25 heeft Youness Alaoui het volgende geschreven:

> that means double disk space and double code complexity, while  
> 'original' getting downloaded is very
> simple code and not that problematic since it's P2P and it's pretty  
> fast..
>
> On Thu, Sep 06, 2007 at 04:49:59PM +0100,  
> [EMAIL PROTECTED] wrote:
>> On 06/09/07, Youness Alaoui <[EMAIL PROTECTED]> wrote:
>>>
>>> Hi,
>>> I'll look at this later, when I get time. Thanks for sending the  
>>> patches.
>>> About the resize to original, it's there for a reason, you  
>>> sometimes need
>>> to resize to 'original', also
>>> 'original' means by definition, that it would need to fetch it  
>>> again.
>>> Think about this.. a user has his DP's original size set to  
>>> 150x150.. you
>>> do a set to original, with
>>> your patch, it gets resized to 96x96, which is wrong..
>>> Also, I sometimes use the 'original' when I want it to  
>>> redownload.. try
>>> for example setting to huge,
>>> then small, then huge, then small, then 'normal'.. what do you  
>>> see ? very
>>> very bad image quality, which
>>> is why you do 'original', to get back that image quality you lost...
>>
>>
>> Maybe the original should be stored somewhere so you can resize  
>> from *that*
>> each time and not lose all that quality?
>> Just a thought :)
>>
>> About the resize thing, it's a good thing it's getting done, I  
>> always knew
>>> about the bug, but never
>>> did.. but the 200ms workaround is not really a good idea.. I  
>>> *think* that
>>> what I do is to set a
>>> callback on Configure and then do a [winfo width] or something..  
>>> which is
>>> why it does that, because the
>>> width/height are not yet updated.. I think the best solution is  
>>> to use the
>>> %W and %H of the bind
>>> command. Read the bind manual to see the options and see if we  
>>> can get the
>>> new width and height with
>>> the % modifier.. this way, no need to have a 200ms gap, + should  
>>> work on
>>> maximimze.
>>>
>>> KaKaRoTo
>>>
>>> On Thu, Sep 06, 2007 at 08:32:49AM +0000, square87 wrote:
>>>> Hi
>>>>
>>>> chatwindow.tcl
>>>>
>>>> @@ -533,26 +541,17 @@ U @@ -3693,6 +3702,10 @@
>>>> So... if lesstab and moretab pics are shown and if i maximize
>>> chatwindows i
>>>> still see them, but delaying "::ChatWindow::CheckForTooManyTabs  
>>>> $window
>>> 0"
>>>> about 200ms resolve the problem. But the bug is still  
>>>> reproducible in
>>> this
>>>> way:
>>>> 1) Open a chatwindow and maximize it
>>>> 2) Disable: "Save chat window size as default when resizing it"
>>>> 3) Open 3 tabs
>>>> 4) Resize chatwindow until only two tabs are showed: now lesstab  
>>>> and
>>> moretab
>>>> should appear
>>>> 5) Maximize chatwindow: the widget where there are tabs are not  
>>>> updated
>>> and
>>>> lesstab and moretab are still shown
>>>>
>>>> @@ -3012,21 +3011,31 @@
>>>> A solution for http://www.amsn-project.net/forums/viewtopic.php? 
>>>> t=3471
>>>> After 8 users in a multichat only 7 users are shown and then  
>>>> there is a
>>> msg
>>>> "There are X others users. To see all users go in: Contact ->
>>> Propierities.
>>>> ", that should go in langen.
>>>>
>>>> @@ -2329,16 +2329,20 @@
>>>> I put also scrollbar-x because i cannot see longs strings ( long  
>>>> nick +
>>>> status + userlogin). I can always maximize the window, but...
>>>> What do you think about to order nicks in alphabetical order? :P
>>>>
>>>> skins.tcl and msnp2p.tcl
>>>> About:
>>> http://www.amsn-project.net/forums/viewtopic.php?t=3972&highlight=
>>>> I found this solution...it checks the previous size of dp in  
>>>> chatwindow
>>> and
>>>> it reloads with the previous size. Then in protocol.tcl, i added  
>>>> a new
>>> value
>>>> when we call the proc ::MSNP2P::loadUserPic to load a new dp it  
>>>> this way
>>>> getDisplayPicture knows that it have to set a new dp with a new  
>>>> size and
>>> no
>>>> with last size.
>>>>
>>>> When we set a dp in a chatwindow with another size (huge, for  
>>>> example)
>>> and
>>>> then we want to set it with the original size we have:
>>>> if [::config::getKey autoresizedp] is enabled we download again  
>>>> the DP
>>> and
>>>> we see it in default size, else if the opt is disabled we cannot  
>>>> see it
>>> in
>>>> original size.
>>>> How to reproduce:
>>>> 1) Disable: Automatically resize display pictures to default size
>>>> 2) Open a chatwindow, show the user's avatar as huge
>>>> 3) set the user's avatar as "original" -> nothing happen
>>>> But when we want re-set a DP in original size, we don't need to  
>>>> download
>>> it
>>>> again just resize for this i put in getDisplayPicture:
>>>>         if {$opz == 2} { ;# opz is 2 when ::MSNP2P::loadUserPic is
>>> called
>>>> when reload as 1
>>>>             if {[::config::getKey autoresizedp]} {
>>>>                 ::picture::Resize $picName 96 96
>>>>             }
>>>>             return $picName
>>>>         }
>>>> So when we want to re-set a dp we have now that:
>>>> we can set dp in original size when autoresizedp is 0, while when
>>>> autoresizedp is 1 we don't download again dp to show it in  
>>>> default size.
>>>>
>>>> Sorry for my English
>>>> Bye
>>>
>>>> Index: chatwindow.tcl
>>>> ===================================================================
>>>> --- chatwindow.tcl    (revision 8995)
>>>> +++ chatwindow.tcl    (working copy)
>>>> @@ -533,26 +541,17 @@
>>>>                       after 200 [list ::ChatWindow::TopUpdate  
>>>> $chatid]
>>>>               }
>>>>
>>>> -             set geometry [wm geometry $window]
>>>> -             set pos_start [string first "+" $geometry]
>>>> -             #Look if the window changed size with the configure
>>>> -
>>>> -             if {[::config::getKey wincontainersize] !=  
>>>> "[string range
>>> $geometry 0 [expr {$pos_start-1}]]"} {
>>>> -                     set sizechanged 1
>>>> -             } else {
>>>> -                     set sizechanged 0
>>>> -             }
>>>> -
>>>>               #Save size of current container
>>>>               if { [::config::getKey savechatwinsize] } {
>>>> +                     set geometry [wm geometry $window]
>>>> +                     set pos_start [string first "+" $geometry]
>>>>                       ::config::setKey wincontainersize  [string  
>>>> range
>>> $geometry 0 [expr {$pos_start-1}]]
>>>>               }
>>>>
>>>> -             #If the window changed size use checkfortoomanytabs
>>>> -             if { [winfo exists ${window}.bar] && $sizechanged} {
>>>> -                     CheckForTooManyTabs $window 0
>>>> +             if { [winfo exists ${window}.bar]} {
>>>> +                     after cancel [list
>>> ::ChatWindow::CheckForTooManyTabs $window 0]
>>>> +                     after 200  
>>>> [list ::ChatWindow::CheckForTooManyTabs
>>> $window 0]
>>>>               }
>>>> -
>>>>       }
>>>>
>>>>
>>> #/////////////////////////////////////////////////////////////////// 
>>> ////////////
>>>> @@ -3012,21 +3011,31 @@
>>>>
>>>>               set camicon [::skin::loadPixmap camicon]
>>>>
>>>> +             set count_users 0
>>>>               foreach user_login $user_list {
>>>> +                     incr count_users
>>>> +                     if {$count_users > 7} {
>>>> +                             set len [expr [llength $user_list] -
>>> $count_users + 1]
>>>> +                             if {$len != 1} {
>>>> +                                     set warningtext "There are  
>>>> $len
>>> others users. To see all users go in: Contact -> Propierities. "
>>>> +                                     $top insert text end  
>>>> $warningtext
>>>> +                                     break
>>>> +                             }
>>>> +                     }
>>>>
>>>>                       set shares_cam [::abook::getContactData
>>> $user_login webcam_shared]
>>>>
>>>>                       if { [::config::getKey  
>>>> emailsincontactlist] == 1 }
>>> {
>>>>                               set user_name ""
>>>>                       } else {
>>>>                               set user_name [string map {"\n" " "}
>>> [::abook::getDisplayNick $user_login]]
>>>>                       }
>>>>                       set state_code [::abook::getVolatileData
>>> $user_login state]
>>>>
>>>> -                     set psmmedia [::abook::getpsmmedia  
>>>> $user_login]
>>>> -
>>>>                       if { [::config::getKey psmplace] == 0 } {
>>>>                               set psmmedia ""
>>>> +                     } else {
>>>> +                             set psmmedia [::abook::getpsmmedia
>>> $user_login]
>>>>                       }
>>>>
>>>>                       #Space added so it doesn't stick next to the
>>> status
>>>> @@ -3693,6 +3702,10 @@
>>>>               variable containerwindows
>>>>               variable visibletabs
>>>>               variable win2tab
>>>> +
>>>> +             if {![winfo exists ${container}.bar]} {
>>>> +                     return
>>>> +             }
>>>>               set bar_w [winfo width ${container}.bar]
>>>>               set tab_w [image width [::skin::loadPixmap tab]]
>>>>
>>>> Index: msnp2p.tcl
>>>> ===================================================================
>>>> --- msnp2p.tcl        (revision 8995)
>>>> +++ msnp2p.tcl        (working copy)
>>>> @@ -130,8 +130,9 @@
>>>>
>>>>
>>>>       #Get picture from $user, if cached, or sets image as  
>>>> "loading",
>>> and request it
>>>>       #using MSNP2P
>>>> -     proc loadUserPic { chatid user {reload "0"} } {
>>>> +     #If $new == 1 it means that an users has changed his picture
>>>> +     proc loadUserPic { chatid user {reload 0} {new 0}} {
>>>>               global HOME
>>>>
>>>>               #Line below changed from != -1 to == 0 because -1  
>>>> means
>>>> @@ -155,11 +156,11 @@
>>>>                       return
>>>>               }
>>>>
>>>> -             #Reload 1 means that we force aMSN to reload a new  
>>>> display
>>> pic
>>>> +             #Reload 1 means that we force aMSN to reload the  
>>>> display
>>> pic with default or original size
>>>>               #Destroy it before to avoid TkCxImage to redraw  
>>>> animated
>>> gif above the good display pic
>>>>               #TODO: FIX: I think the next line is incorrect,  
>>>> did you
>>> want image delete? (be careful if there are images on the screen)
>>>>               destroy user_pic_$user
>>>> -             if { ![file readable "[file join $HOME displaypic  
>>>> cache
>>> ${filename}].png"] || $reload == "1" } {
>>>> +             if { ![file readable "[file join $HOME displaypic  
>>>> cache
>>> ${filename}].png"]} {
>>>>                       status_log "::MSNP2P::GetUser: FILE [file  
>>>> join
>>> $HOME displaypic cache ${filename}] doesn't exist!!\n" white
>>>>                       image create photo user_pic_$user -file
>>> [::skin::GetSkinFile "displaypic" "loading.gif"] -format cximage
>>>>
>>>> @@ -179,14 +180,16 @@
>>>>                               } else {
>>>>                                       image delete
>>> displaypicture_not_$user
>>>>                               }
>>>> -                     }
>>>> -
>>>> +                     }
>>>>
>>>>                       create_dir [file join $HOME displaypic]
>>>>                       create_dir [file join $HOME displaypic cache]
>>>>                       ::MSNP2P::RequestObject $chatid $user $msnobj
>>>> +             } elseif { $reload == 1} {
>>>> +                     ::skin::getDisplayPicture $user 1 2
>>>> +                     ::amsn::UpdateAllPictures
>>>>               } else {
>>>> -                     ::skin::getDisplayPicture $user 1
>>>> +                     ::skin::getDisplayPicture $user 1 $new
>>>>               }
>>>>       }
>>>>
>>>> Index: protocol.tcl
>>>> ===================================================================
>>>> --- protocol.tcl      (revision 8995)
>>>> +++ protocol.tcl      (working copy)
>>>> @@ -5059,17 +5059,17 @@
>>>>                               set users_in_chat [$sb cget -users]
>>>>                               if { [lsearch $users_in_chat  
>>>> $user] != -1
>>> } {
>>>>                                       status_log "User changed  
>>>> image
>>> while image in use!! Updating!!\n" white
>>>> -                                     ::MSNP2P::loadUserPic
>>> [::MSN::ChatFor $sb] $user
>>>> +                                     ::MSNP2P::loadUserPic
>>> [::MSN::ChatFor $sb] $user 0 1
>>>>                               }
>>>>                       }
>>>>               } else {
>>>>                       if { [::MSN::myStatusIs] != "FLN" &&
>>> [::MSN::myStatusIs] != "HDN"} {
>>>>                               if { ![file readable "[file join  
>>>> $HOME
>>> displaypic cache ${newPic}].png"] } {
>>>>                                       set chat_id [::MSN::chatTo  
>>>> $user]
>>>> -                                     ::MSN::ChatQueue $chat_id  
>>>> [list
>>> ::MSNP2P::loadUserPic $chat_id $user]
>>>> +                                     ::MSN::ChatQueue $chat_id  
>>>> [list
>>> ::MSNP2P::loadUserPic $chat_id $user 0 1]
>>>>                               } else {
>>>>                                       #We already have the image so
>>> don't open a convo to get it just load it
>>>> -                                     ::MSNP2P::loadUserPic ""  
>>>> $user
>>>> +                                     ::MSNP2P::loadUserPic ""  
>>>> $user 0 1
>>>>                               }
>>>>                       }
>>>>               }
>>>> Index: gui.tcl
>>>> ===================================================================
>>>> --- gui.tcl   (revision 8995)
>>>> +++ gui.tcl   (working copy)
>>>> @@ -2329,16 +2329,20 @@
>>>>               frame $wname.blueframe.list -class Amsn - 
>>>> borderwidth 0
>>>>               frame $wname.buttons -class Amsn
>>>>
>>>> -             listbox $wname.blueframe.list.items -yscrollcommand
>>> "$wname.blueframe.list.ys set" -font splainf \
>>>> +             listbox $wname.blueframe.list.items -yscrollcommand
>>> "$wname.blueframe.list.ys set" -xscrollcommand  
>>> "$wname.blueframe.list.xs
>>> set" -font splainf \
>>>>                       -background white -relief flat - 
>>>> highlightthickness
>>> 0 -height 20 -width 60
>>>>               scrollbar $wname.blueframe.list.ys -command
>>> "$wname.blueframe.list.items yview" -highlightthickness 0 \
>>>>                       -borderwidth 1 -elementborderwidth 1
>>>>
>>>> +             scrollbar $wname.blueframe.list.xs -orient horizontal
>>> -command "$wname.blueframe.list.items xview" -highlightthickness 0 \
>>>> +                     -borderwidth 1 -elementborderwidth 1
>>>> +
>>>>               button  $wname.buttons.ok -text "[trans ok]" -command
>>> [list ::amsn::listChooseOk $wname $itemlist $command]
>>>>               button  $wname.buttons.cancel -text "[trans cancel]"
>>> -command [list destroy $wname]
>>>>
>>>>
>>>>               pack $wname.blueframe.list.ys -side right -fill y
>>>> +             pack $wname.blueframe.list.xs -side bottom -fill x
>>>>               pack $wname.blueframe.list.items -side left - 
>>>> expand true
>>> -fill both
>>>>               pack $wname.blueframe.list -side top -expand true - 
>>>> fill
>>> both -padx 4 -pady 4
>>>>               pack $wname.blueframe -side top -expand true -fill  
>>>> both
>>>> @@ -2356,7 +2360,7 @@
>>>>               pack $wname.buttons -side bottom -fill x -pady 3
>>>>
>>>>               foreach item $itemlist {
>>>> -                     $wname.blueframe.list.items insert end  
>>>> [lindex
>>> $item 0]
>>>> +                     $wname.blueframe.list.items insert end  
>>>> "[lindex
>>> $item 0] - ([lindex $item 1])"
>>>>               }
>>>>
>>>>
>>>> Index: skins.tcl
>>>> ===================================================================
>>>> --- skins.tcl (revision 8995)
>>>> +++ skins.tcl (working copy)
>>>> @@ -234,7 +234,9 @@
>>>>               return displaypicture_std_none
>>>>       }
>>>>
>>>> -     proc getDisplayPicture { email {force 0}} {
>>>> +     # $opz == 1 the user has changed his pics
>>>> +     # $opz == 2 we want to show the pic in the original or  
>>>> default
>>> size
>>>> +     proc getDisplayPicture { email {force 0} {opz 0}} {
>>>>               global HOME
>>>>
>>>>               set picName displaypicture_std_$email
>>>> @@ -242,10 +244,15 @@
>>>>               if { [::abook::getContactData $email client] ==
>>> "Webmessenger" } {
>>>>                       return [::skin::loadPixmap webmsn_dp]
>>>>               }
>>>>               if {[catch {image width $picName}] == 0  && $force  
>>>> == 0} {
>>>>                       return $picName
>>>>               }
>>>>
>>>> +             if { [catch {image width $picName} personalsize] } {
>>>> +                     set personalsize -1
>>>> +             }
>>>> +
>>>>               if { [::abook::getContactData $email customdp] !=  
>>>> "" } {
>>>>                       set filename [::abook::getContactData $email
>>> customdp ""]
>>>>                       # As custom DP can also be stored outside the
>>> cache folder,
>>>> @@ -267,16 +274,26 @@
>>>>               }
>>>>
>>>>               if {[catch {image width $picName} res]} {
>>>>                       #status_log "Error while loading $picName:  
>>>> $res"
>>>>                       image create photo $picName
>>>>                       $picName copy [::skin::getNoDisplayPicture]
>>>>                       set file [::skin::GetSkinFile displaypic  
>>>> nopic.gif
>>> ]
>>>>               }
>>>>
>>>> +             if {$opz == 2} {
>>>> +                     if {[::config::getKey autoresizedp]} {
>>>> +                             ::picture::Resize $picName 96 96
>>>> +                     }
>>>> +                     return $picName
>>>> +             }
>>>>
>>>>               if { [catch {::picture::GetPictureSize $file}  
>>>> cursize] } {
>>>>                       #Corrupted image.. might as well delete it  
>>>> and
>>> redownload it some other time..
>>>>                       status_log "Error opening $file: $cursize\n"
>>>>                       catch {file delete $file}
>>>> +             } elseif {![::config::getKey autoresizedp] && $opz  
>>>> == 0 &&
>>> $personalsize != -1} {
>>>> +                     ::picture::Resize $picName $personalsize
>>> $personalsize
>>>>               } elseif { [::config::getKey autoresizedp] &&
>>> ![::picture::IsAnimated $file] && $cursize != "96x96"} {
>>>>                       ::picture::Resize $picName 96 96
>>>>               }
>>>>
>>> -------------------------------------------------------------------- 
>>> -----
>>>> This SF.net email is sponsored by: Splunk Inc.
>>>> Still grepping through log files to find problems?  Stop.
>>>> Now Search log events and configuration files using AJAX and a  
>>>> browser.
>>>> Download your FREE copy of Splunk now >>  http://get.splunk.com/
>>>> _______________________________________________
>>>> Amsn-devel mailing list
>>>> Amsn-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/amsn-devel
>>>
>>>
>>> -------------------------------------------------------------------- 
>>> -----
>>> This SF.net email is sponsored by: Splunk Inc.
>>> Still grepping through log files to find problems?  Stop.
>>> Now Search log events and configuration files using AJAX and a  
>>> browser.
>>> Download your FREE copy of Splunk now >>  http://get.splunk.com/
>>> _______________________________________________
>>> Amsn-devel mailing list
>>> Amsn-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/amsn-devel
>>>
>
>> --------------------------------------------------------------------- 
>> ----
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?  Stop.
>> Now Search log events and configuration files using AJAX and a  
>> browser.
>> Download your FREE copy of Splunk now >>  http://get.splunk.com/
>> _______________________________________________
>> Amsn-devel mailing list
>> Amsn-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/amsn-devel
>
>
> ---------------------------------------------------------------------- 
> ---
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a  
> browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Amsn-devel mailing list
> Amsn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amsn-devel


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel

Reply via email to