package require Img
package require img::raw
set f [open "a_big_file" r]
fconfigure $f -translation binary
set f_content [read $f]
close $f
set photo2 [image create photo -format "raw -useheader 0 -nomap 1
-verbose 1 -width 320 -height 240 -nchan 3 -pixeltype byte" -data
$f_content]
label .l2 -image $photo2
pack .l2
I don't understand what I am doing wrong, the image is fully black but
should be "noise"... do you have an exemple of how to use img::raw???
Best regards,
Alexandre.
You're right, apparently there's a bug with the computation of the
default 'max' pixel value, and it stays zero, hence all pixels get
mapped to black.
I discovered this by looking at the output from the "-verbose 1":
Reading image: InlineData
Size in pixel : 320 x 240
No. of channels : 3
Pixel type : byte
Vertical encoding: TopDown
Gamma correction : 1.000000
Minimum map value: 0.000000
==> Maximum map value: 0.000000
Host byte order : Intel
File byte order : Intel
So you can work around this bug by adding the "-max 255" option.
But also be sure to create a bug report for the Img package...
-Alex (aussi)
then the second time the image turn to black again. It seems that
parameters are not taken into account (although the verbose mode write
Maximum map value: 255.000000 on the console).
Ok, I will post a bug report ^_^
On 27 août, 14:32, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:
I have added a new option (-uuencode bool) to the RAW format handler
(SVN Revision 300).
It is set to true by default, so the standard behaviour is not changed.
Note, that this only happens, if you supply the RAW image data without
header information via a Tcl variable.
If you don't want to update to the new Img version, you have the
following options:
# Method 1: Read directly from file with method "read".
set photo1 [image create photo]
$photo1 read $inFile \
-format "raw -nomap 1 -useheader 0 -verbose 1 -width $width
-height $height -nchan 3"
# Method 2: Read directly from file with option "-file".
set photo2 [image create photo -file $inFile \
-format "raw -nomap 1 -useheader 0 -verbose 1 -width $width
-height $height -nchan 3"]
If you update to the new Img version, you can do it this way:
# Method 3: Read from variable with method "put" and new option
"-uuencode".
# Only works with new version of Img.
set photo3 [image create photo]
$photo3 put $f_data \
-format "raw -nomap 1 -useheader 0 -verbose 1 -width $width
-height $height -nchan 3 -uuencode 0"
P.S.:
I have uploaded Img binaries of SVN revision 300 for Windows, Linux and
Mac to http://www.posoft.de/html/extTkImg.html
Paul