Tk Source Code

View Ticket
Login
Ticket UUID: 232213
Title: ImgName -data will not take 1 pixel wide/high rectangles
Type: Bug Version: obsolete: 8.3.2
Submitter: scfiead Created on: 2001-02-13 19:23:13
Subsystem: 39. Image Basics Assigned To: ericm
Priority: 1 Zero Severity:
Status: Closed Last Modified: 2001-02-14 03:13:49
Resolution: Invalid Closed By: ericm
    Closed on: 2001-02-13 19:39:41
Description:
ImgName -data fails to select anything if the box provided by x1 y1 x2 y2 has either a height or width of 1 pixel (x1=x2 or y1=y2).  Minimum selection size becomes 2x2 pixels.

The software should allow a 1 pixel wide selection.

Ryan P. Casey
User Comments: scfiead added on 2001-02-14 03:13:49:
Hmmm..indeed.

I was fairly sure that I tested this thoroughly back when I first did it, but I may have been mistaken.  I didn't realize that it was a [x,y) scheme...I thought it pulled the entire rectangle of pixels specified.

After reading the man page it still does not seem clear that the -from would not include the specified x2, y2 pixels:
-from x1 y1 x2 y2
  Specifies a rectangular region of imageName to be written to the image file. If only x1 and y1 are specified, the region extends from (x1,y1) to the bottom-right corner of imageName. If all four coordinates are given, they specify diagonally opposite corners of the rectangular region. The default, if this option is not given, is the whole image. 

Since I do not know how to update man pages, may I request that this be changed to a Man Page update request that specifies that a little better where appropriate? (i.e. I am not sure whether there are other sections like this in the man pages that are ambiguous on the subject of x2, y2 inclusion... -copy to?  -copy from? -read from?  etc.

ericm added on 2001-02-14 02:39:41:
"imgName -data" is not a command per se; there's "image create photo -data" and "imgName data -from x1 y1 x2 y2".  Of those two, I assume you mean the second.  The example you give, in which x1=x2 or y1=y2 , is specifying a zero width or height region.  To specify a one width region, use x2 = x1 + 1.  For example:

% image create photo -file folderopen.gif
image1
% image1 data -from 0 0 1 1
#000000
% image1 data -from 10 10 11 11  
#3e4e62
% image1 data -from 10 10 12 12
{#3e4e62 #3e4e62} {#0b0b0b #0b0b0b}
% exit

As you can see, the first two calls successfully return a single pixel (or a
1x1 pixel region, if you prefer); the third returns a 2x2 pixel region.

Using mathematical notation, the region selected is [x1,x2) (ie, including x1, excluding x2), [y1, y2).

Eric Melski
The Other Tcl Guy
Interwoven, Inc.