Menu

#2130 image read file from co-ords

obsolete: 8.5a4
open
5
2006-12-05
2006-10-13
No

The /image/ read /file/ -from x1 y1 x2 y2 command does
not work correctly. The following script uses the
ActiveTcl example gif of the earth from space. The
rectangular region (152,62) to (185,97) encloses
Madagascar. The displayed region is from the top-right
hand corner.

package require Tk
set fname C:/Tcl8.4/demos/Tk8.4/images/earth.gif
canvas .c
pack .c
set img [image create photo]
$img read $fname -from 152 62 185 97
.c create image 0 0 -anchor nw -image $img

Discussion

  • Alastair Davies

    Alastair Davies - 2006-10-13

    Logged In: YES
    user_id=988604

    Just for comparison, here is the equivalent /image/ copy
    /image/ -from x1 y1 x2 y2 code, which does work correctly.

    package require Tk
    set fname C:/Tcl8.4/demos/Tk8.4/images/earth.gif
    canvas .c
    pack .c
    set img1 [image create photo -file $fname]
    set img2 [image create photo]
    $img2 copy $img1 -from 152 62 185 97
    .c create image 0 0 -anchor nw -image $img2

     
  • Donal K. Fellows

    • assigned_to: nobody --> dkf
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.