Re: Displaying a Pixmap
- From: zentara <zentara1 sbcglobal net>
- To: gtk-perl-list gnome org
- Subject: Re: Displaying a Pixmap
- Date: Mon, 26 Feb 2007 12:13:10 -0500
On Sun, 25 Feb 2007 14:52:25 -0500
"Scott White" <whitews gmail com> wrote:
Hi all,
I am writing an application that reads medical imaging files (CT, MRI, etc
in DICOM format) and simply displays them. However, I am having trouble
using Gtk2::Gdk::Pixmap. I must use a pixmap since DICOM images are usually
16-bit, and almost always grayscale.
I believe the problem lies within the pixmap method "create_from_data" where
the first parameter is supposed to be a Gtk2::Gtk::Drawable. If I create
just a simple drawable, the program complains that the object is undefined.
Yeah, IIRC, if you look at the "scribble" example in the demo, you will see that
the main window needs to be up-and-visible, before anything is considered
drawable. To test your script, I used a button to launch an image
loader sub, after the window was up and running. That avoided the undefined
error. The scribble example used the expose and configure events, but I just
hacked a button.
So, I get the root window using "get_default_root_window" since the
Gtk2::Gdk::Window is technically a Drawable. I admit to not fully
understanding the difference between Gtk2::Window and Gtk2::Gdk::Window.
From my understanding, the Gtk2::Gdk::Window is the actual window area
on the screen, it is a low level window that every widget has, like
$widget->window. The problem with Gdk windows is that they are not persistent,
if you cover them, their data will dissapear on the next expose event.
See: http://perlmonks.org?node_id=583578 for a walk thru on how it works.
Any help would be greatly appreciated, as I'm now wandering around aimlessly
with several baldspots.
Scott
I ran into the same problem when I tried to display a sample DICOM,
it says
" Attempt to draw a drawable with depth 16 to a drawable with depth 24"
As I played around, it seems the default depth for the Viewport I tried to
write to is 24, and I can't find a place to change it. So I'm guessing you need to
unpack the 16 bit file and repack it as 24? And there is the problem of
lopping of the header, to get to the actual data. If anyone is interested in
playing with this, here is a free sample DICOM image and it's info file.
http://barre.nom.fr/medical/samples/files/CT-MONO2-16-brain.gz
http://barre.nom.fr/medical/samples/files/CT-MONO2-16-brain.txt
As a quick work-around, (until muppet solves this :-) ), there is a Gtk2-c
package at http://aeskulap.nongnu.org/, that works well. Maybe you can
gleam how they did it?
Another option to use, is to convert the DICOM, with ImageMagick, to some
format the pixbuf loader likes, such as bmp or png.
The IM "display" command seems to display a DICOM image, so I sure it can
convert it.
Goodluck,
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]