Newsgroup: it.comp.programmare.win32
Titolo: FreeImage e visualizzazione immagini

Ho scaricato FreeImage da
http://sourceforge.net/projects/freeimage
C'e' un esempio chiamato GraphicSuite, scritto in Visual C++, ed ho cercato
di quale e' il modo di utilizzare la libreria per visualizzare, in un mio
programma Visual C++, una immagine (nel mio caso TIF, ma non e' questo che
importa).
Il punto e' che non riesco a capire, una volta caricata l'immagine con
FreeImage_LoadImage(), come *visualizzare* l'immagine. Penso che questa non
sia questione di FreeImage, ma di MFC.
FreeImage_LoadImage restituisce un puntatore all'immagine caricata in
memoria, ma... come si utilizza?
Grazie per l'attenzione.
-- 
"Tutti sanno che una cosa e' impossibile da realizzare, finche'
arriva uno sprovveduto che non lo sa e la inventa."
(Albert Einstein)

 memoria, ma... come si utilizza?
Ho visto nella documentazione FreeImage_Load() e non FreeImage_LoadImage 
...forse pero' ho visto male io...
Comunque mi pare che vi siano delle API come FreeImage_GetBits() che 
dovrebbero consentirti di accedere alla bitmap vera e propria (con 
FreeImage_GetWidth/Height() avrai poi le info circa le dimensioni della 
bitmap).
Se hai i bit della bitmap (tramite FreeImage_GetBits()) a quel punto 
puoi usare le API DIB di Win32 per la visualizzaizone. 
...Non vorrei dire una inesattezza, ma mi pare che MFC _non_ abbia una 
classe per gestire le DIB, quindi credo che si debba ricorrere 
direttamente alle API Win32 (CreateDIBSection() e compagne).
CodeNinja

memoria, ma... come si utilizza?
Dalla FAQ di FreeImage:
How do i draw a FreeImage image to the screen in Windows? 
--------------------------------------------------------------------------------
FIBITMAP *dib = FreeImage_LoadBMP("test.bmp", BMP_DEFAULT);
SetDIBitsToDevice(hdc, x, y, FreeImage_GetWidth(dib),
  FreeImage_GetHeight(dib), 0, 0, 0,
  FreeImage_GetHeight(dib), FreeImage_GetBits(dib),
  FreeImage_GetInfo(dib), DIB_RGB_COLORS); 
 
How do i convert a FreeImage image to a HBITMAP? 
--------------------------------------------------------------------------------
FIBITMAP *dib = FreeImage_LoadBMP("test.bmp", BMP_DEFAULT);
HBITMAP bitmap = CreateDIBitmap(hdc,
  FreeImage_GetInfoHeader(dib),
  CBM_INIT,
  FreeImage_GetBits(dib),
  FreeImage_GetInfo(dib),
  DIB_RGB_COLORS);
 
How do i convert a HBITMAP to a FreeImage image? 
--------------------------------------------------------------------------------
BITMAP bmp;
GetObject(hbmScreen, sizeof(BITMAP), (LPSTR)&bmp);
int cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
FIBITMAP *dib = FreeImage_Allocate(bmp.bmWidth, bmp.bmHeight,
cClrBits);
GetDIBits(hdcScreen, hbmScreen, 0, bmp.bmHeight,
FreeImage_GetBits(dib),
  FreeImage_GetInfo(dib), DIB_RGB_COLORS);
Ciao
Paolo

 Dalla FAQ di FreeImage:
...
Grazie mille!!!

Come è possibile accedere alle faq di FreeImage?
E' possibile avere il link?
Grazie!

E' possibile avere il link?
Il link e' 
http://www.6ixsoft.com/
purtroppo il sito e' ormai vuoto perche' lo sviluppo di FreeImage e'
stato interrotto.
Paolo

 Il link e' 
http://www.6ixsoft.com/
purtroppo il sito e' ormai vuoto perche' lo sviluppo di FreeImage e'
stato interrotto.
 Paolo
Si ho già visto il link...è possibile ricevere le faq che tu hai visto che
ho notato che ne hai qualcuna?
Grazie
Vincenzo

ho notato che ne hai qualcuna?
Questa e' la faq che era sul sito:
=========================
Frequenty Asked Questions
Why did you decide to make FreeImage?
--------------------------------------------------------------------------------
I have always believed in the importance of easy to use development
software; i think no library exists today that is easy, but also
powerful and fast. With FreeImage I tried to deliver such a library
and i think, seeing the large user base and the tremendous number of
hits on my homepage, i succeeded quite well. Thanks to all the support
of many people like Herve Drolon, Jan Nauta, Markus Loibl, Alexander
Dymerets, Martin Weber and all others i forgot to mention ofcourse! 
On yeah, i have to mention that portions of FreeImage are co-owned by
the Magenta II Multimedia Tools (
http://www.magentammt.com/
). 
What are the plans for FreeImage 3.x?
--------------------------------------------------------------------------------
Besides a cleanup of the API, and a CVS repository I don't know yet :)
Why don't make a suggestion in the Yahoo Groups mailing list? 
Can I use FreeImage in a commercial program, without distributing my
sourcecode?
--------------------------------------------------------------------------------
Yes. You don't have to ship your sourcecode with your program in order
to use FreeImage, nor do you have to make it possible to let people
link with newer versions of the DLL. You can even statically link
FreeImage in your application. You DO have to make it evident though
that you are using FreeImage, by either putting a message in your
program's About Box or by putting a notification in your manual. Also,
if you change something to the library or add a new feature, you are
highly encouraged to send this change/addition back to the FreeImage
Community. 
Will FreeImage support TIFF-LZW or GIF_LZW?
--------------------------------------------------------------------------------
No. 
I actually tried to persuade Unisys to give me a LZW-license. When
they refused, i asked them to send me a license agreement. In my mind,
if the price to enter such an agreement would be reasonable, i could
ask a low fee for the GIF plugin and the TIFF plugin and sell them to
those who would enter a commercial agreement with Unisys. This is the
agreement they sent me: 
"Following is a copy of the TIFF-LZW/GIF-LZW license for distributing
toolkit and other development type software running on PCs and
workstations. [...] Under the terms of this agreement you may NOT
deliver software with LZW (GIF or TIFF-LZW) capability unless the
company to receive the software has previously entered an agreement
directly with Unisys allowing them to use your software. Should you
wish to enter into this agreement with Unisys, you should have an
authorized representative of your company and return both copies (all
pages) to the address given on the top of this agreement along with
your check made payable to Unisys Corporation for $3,500.00 (U.S.)
Registration Fee. [...] Note that Unisys reserves the right not to
enter a license with your company and may/require additional
information in order to make such determination.". Then 6 pages of
legal blahblah, where they claim the right to terminate the awfully
expensive license for 16 lines of code at anytime. 
Even if i had $3,500.00 i wouldn't spend one dime of it on Unisys. GIF
will not be supported. See 
http://burnallgifs.org/
 for more
information about the LZW patent and why PNG is a better choice for
web-graphics. 







How does the multi-paging system work? 
--------------------------------------------------------------------------------
When using the multi-paging system, things are a bit different what
you are used to. The bitmaps you retrieve from a multi-bitmap (e.g. a
TIFF with multiple pages) are 'managed', which means that they are
loaded and unloaded by the multi-page system as it sees fit. Because
of this you may never call FreeImage_Unload/FreeImage_Free on a bitmap
retrieved using FreeImage_LockPage, but instead must call
FreeImage_unlockPage. 
 // **************************************************
// the parameters in FreeImage_OpenMultiBitmap mean:
// 1) selector for the bitmap plugin. currently the only one
//    supported is FIF_TIFF
// 2) name of the file to be opened
// 3) true to create a new bitmap, false to open an existing one
// 4) true to open a bitmap read-only, false to allow writing. ignored
//    when the previous parameter is true
// 5) true if the multi-page system should keep all gathered bitmap
//    data in memory, false to flush lazy to disc
// **************************************************
FIMULTIBITMAP *mbmp = FreeImage_OpenMultiBitmap(FIF_TIFF,
"mybitmap.tiff", false, false, false);
// Lock the first page... the page can now be saved to another
// file, or changed in memory
FIBITMAP *page = FreeImage_LockPage(mbmp, 0);
// Unlock the page... if the last parameter is true, the bitmap
// has been changed in memory. The new bitmap is then - beneath
// the surface - compressed and stored in a bitmap cache.
FreeImage_UnlockPage(mbmp, page, false);
// Close the multibitmap. If the bitmap is changed, a new bitmap
// is written to a .spool file and then renamed to the original.
FreeImage_CloseMultiBitmap(mbmp);