From: Johan L. <jo...@ba...> - 2002-01-08 02:44:29
|
At 17:40 2002-01-07 -0800, Glenn Linderman wrote: >ImageMagick can do lots of nice conversions of whatever graphic format >to BMP format, if that is what Win32::GUI::Bitmap needs. Yes, that's what you want. >How can I get from there, to a window that displays the data? Do I have >to > >$errstr = $image -> Write ( 'xxx.bmp' ); > >as it appears that the Win32::GUI::Bitmap call requires a filename? >use Win32::GUI; >$bitmap = new Win32::GUI::Bitmap ( 'xxx.bmp' ); That would be the first quick solution to get something working until you figure out how to assign the bitmap data directly to object Win32::GUI::Bitmap object. Encapsulate it into a sub or method and you can easily change implementation afterwards. Read up on the graphics stuff in the Win32 API docs. And read the source (Perl + C) for the Bitmap class, that should get you going in the right direction. >And then, having somehow or another a $bitmap reference, how do I >display it in a window? > >I see one possibility of > >$main_window -> AddLabel ( -name => bitmap, -bitmap => $bitmap ); Good approach. And, as mentioned earlier on the list, keep the $bitmap object from being destroyed during the entire lifespan of the label. >Are there any pros or cons of using Labels vs Buttons vs ??? And do you Go with the label. I don't think you can remove the "button look" anyway. >need to specify the exact size of the bitmap as the size of the label? >Or do you need to leave room for borders, and other stuff? Yes. I think there are no margins to consider if you align the image top-left or center-middle. But like you said, experiment, possibly using TGL to get things done fast (save the Design before you add bitmaps and place the bitmap files-in-or-below the .tgl directory). >If there are any scaling capabilities, it'd be nice to know about them, >I didn't find any the first pass through. There is one sample program in the distro, resizing the background of a window. >On the other hand, I fear that none of that will allow me to add scroll >bars to the bitmap, so that I can display a portion of a bigger than >screen image. Difficult. Maybe if you can add a scrollbar style to the bitmap? That _might_ work, possibly... (look at the CreateWindow function in the Win32 API). >I fear I'll have to dive into Win32::GUI::DC to do some >of this... I've been avoiding that so far... but this seems oriented to >line art, rather than bitmap art... If you have to do the DC thing you definitely should take a look at the Win32::GUI:Control::Label control (the Paint method... but the important methods are inherited from Win32::GUI:Control i think, let me know if you can't find them), because there are some really tricky things to consider when painting bitmaps on a device context, like pixel offsets etc. And there are useful utility routines in Win32::GUI::AdHoc for that i think. All modules I mentioned: http://www.bahnhof.se/~johanl/perl/Loft/ /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "Re Newby Query Comment" <http://www.perlmonks.org/index.pl?node_id=71663&lastnode_id=136782> |