From: Glenn L. <Gle...@ne...> - 2002-01-08 01:39:02
|
Hi, ImageMagick for Windows seems to be missing display routines, as the supplied display utility is X based... or did I miss a key point of their documentation? Win32::GUI seems to be able to do something with Bitmaps, but it is not particularly clear just what, or how. ImageMagick can do lots of nice conversions of whatever graphic format to BMP format, if that is what Win32::GUI::Bitmap needs. I'd like to conquer the functionality of loading a file with ImageMagick, and then using Win32::GUI to display it. Loading the file seems to be straightforward: use Image::Magick; $image = Image::Magick -> new; $errstr = $image -> Read ( $filename ); 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' ); or is there a way to avoid the intermediate file? Using the TBD Create method? Or maybe Win32::GUI::BitmapInline? Although this seems to create its own intermediate file. 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 ); Are there any pros or cons of using Labels vs Buttons vs ??? And do you 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? Some of this will probably become clear as I start to experiment. If there are any scaling capabilities, it'd be nice to know about them, I didn't find any the first pass through. 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. 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... Any advice, guidance, or sample code that I could look at for this, before I bang a hole in a wall with my head, and then find out it was the wrong wall!!! would be welcomed. Mostly I'm dealing with monochrome bitmaps, if that simplifies things, but they can get quite large, and scaling and scrolling are requirements to get the job done. -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
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> |
From: Laurent R. <ro...@cl...> - 2002-01-08 19:00:06
|
Hi, I have made a package for read/write/display different image file. You can see some sample in the source zip file. Win32::GUI::DIBitmap add new reading/writing bitmap formats to Win32::GUI and some images manipulations (Conversion, Screen capture, ...). This package uses FreeImage 2.4.1, an open source image library supporting all common bitmap formats (visit : http://www.6ixsoft.com/). Supports many formats, such as: Format Reading Writing Description. BMP Y Y Windows or OS/2 Bitmap ICO Y N Windows Icon JPEG Y Y JPEG - JFIF Compliant JNG Y N JPEG Network Graphics KOALA Y N C64 Koala Graphics IFF Y N IFF Interleaved Bitmap MNG Y N Multiple Network Graphics PBM Y Y Portable Bitmap (ASCII) PBMRAW Y Y Portable Bitmap (RAW) PCD Y N Kodak PhotoCD PCX Y N Zsoft Paintbrush PGM Y Y Portable Greymap (ASCII) PGMRAW Y Y Portable Greymap (RAW) PNG Y Y Portable Network Graphics PPM Y Y Portable Pixelmap (ASCII) PPMRAW Y Y Portable Pixelmap (RAW) RAS Y N Sun Raster Image TARGA Y N Truevision Targa TIFF Y Y Tagged Image File Format WBMP Y Y Wireless Bitmap PSD Y N Adobe Photoshop See more here : http://perso.club-internet.fr/rocherl/Win32GUI.html I 'm working on a new release with FreeImage 2.5.0. Laurent. |