Page 1 of 5

New Image plugin available for beta-testing

Posted: Tue Apr 29, 2003 5:14 pm
by El_Choni
Hi,

It uses the OLE COM API to decode images. According to Microsoft, it should support BMP, ICO, CUR, WMF and EMF files, but it's known to handle GIF and JPEG files as well. I'm not going to argue here about the GIF/LZW issue, I've written some words about that in the help file which comes with the zip, but in short: if OLEAUT32.DLL decodes GIF files, it's not my fault, it comes with Windows, and we all know GIF is an obsolete format, so it's up to you to use this library with GIF files (the library doesn't make any check of the given image file format).

You can download it at:

http://www.terra.es/personal5/temporald ... LE_1.0.zip

Have a look at it and, if you find any bug, please tell me (better not in the bugs forum, but in this same thread).

I have another plugin ready for decoding/encoding PPM files, but I want to release it in a bundle with other image plugins, unless someone is in an urgent need of a PPM plugin, which I doubt.

Other plugins in my TODO list: PBM, PGM, IFF, XPM, XBM, WBMP, TGA encoding, GdiPlus. I have working PB procedures for all of them, so it's only a matter of time to get them translated to Fasm. If you want some format to be included in this list, tell me, and I'll see if I can handle it (the above formats are easy to decode/encode).

Have a nice day,

-- Manolo: estamos con ello, envíame las contraseñas cuando quieras.

Posted: Tue Apr 29, 2003 6:16 pm
by benny
Hi,

does run perfectly on my system (win xp).
well done - keep it up !!!
8)

Regards, benny!

Posted: Tue Apr 29, 2003 8:05 pm
by Fred
Works perfectly on Windows 2000. Very nice work ! So much formats for a such small size 8).

Posted: Tue Apr 29, 2003 8:15 pm
by Berikco
Works just fine on W2K and XP pro
Tested JPG's and GIF's

Posted: Wed Apr 30, 2003 12:10 am
by Henrik
Yeah it works great on win 98 se too :D
and you gotta love the size of the exe :mrgreen:

Regards
Henrik

Posted: Wed Apr 30, 2003 1:37 am
by ricardo
@El_Choni

As usuall, you are a genius!!

Works excellent here in XP.

Posted: Wed Apr 30, 2003 2:27 am
by El_Choni
Well, I gues it works XD. I'll send it to Paul's tomorrow, you've been very kind. Have a nice day,

Posted: Thu Jan 15, 2004 12:16 am
by LCD
Sorry for awakening a dead thread, but there seems to be a really nasty bug. Usualy I replaced the PB Decode JPG plugin by the OLE Plugin in order to save few Kb in my EXE, it worked! I was able to load JPG's and the most important: GIF (because no one is able to code a GIF decoder [Guys, GIF patent has gone, and decoding was never patented!]).
Now after expanding my program without changing anything with image loading stuff, I noticed that it is not possible anymore to load JPG and GIF images, except if the PB debuger is running. The faulty JPG decoding can be replaced by sarcifying some Kb and using the PB's own JPG decoder, but I want the GIF!!! It does not load the GIF's anymore and LoadImage() returns a 0. [Panic!].

Posted: Thu Jan 15, 2004 12:24 am
by Shannara
Heh, not bad. Just remember, currently GIF is the only lossless compression format for images.... so hardly obsolete :) Well, you could include "PNG", but the file size is horrendous.

Posted: Thu Jan 15, 2004 12:29 am
by LCD
I included PNG too, but you're right about the file size. GIF is sometime better., and I cannot affort to not include it. Again sorry for digging in the grave (of both, this thread and GIF), but I have my reasons...

Posted: Thu Jan 15, 2004 12:45 am
by Guimauve
If possible the Zsoft PaintBrush *.pcx image format.

This can be very useful to create images conversion program.


Best Regards

Guimauve

Posted: Thu Jan 15, 2004 1:34 am
by freedimension
Shannara wrote:Heh, not bad. Just remember, currently GIF is the only lossless compression format for images.... so hardly obsolete :) Well, you could include "PNG", but the file size is horrendous.
Nonsense. This is not true.
Almost all Image Formats are lossless, except JPG and a few other not to be mentioned.
Some of them have an option, whether to use lossless or lossy compression (like TIFF does). Even the BMP Format is lossless, although it doesn't support compression for 24Bit Images.
As for the Size, YES GIF is very good here, but if you know how to handle PNG you can get results that are nearly as good. Not to speak of Colordepth, here PNG can handle far more than GIF ever was able to.
The only thing GIF is still unbeaten in, is the possibility for small webanimations.

Posted: Thu Jan 15, 2004 2:25 am
by LCD
Anyway, Danielo from the german forum helped me out with this problem, he made a procedure to decode GIF and JPG using the system resources, and it works. [/Panic off]

Posted: Thu Jan 15, 2004 2:29 am
by Danilo
LCD wrote:Now after expanding my program without changing anything
with image loading stuff, I noticed that it is not possible
anymore to load JPG and GIF images, except if the PB debuger
is running.
See LoadPictureFile()

If you want to include the Image in the EXE or want to load
it from memory, try CatchPictureFile():

Code: Select all

; Original:
;   German forum: http://robsite.de/php/pureboard/viewtopic.php?t=2587&postdays=0&postorder=asc&start=10
;   Author: Danilo
;   Date  : 18. October 2003

; Changed to CatchPictureFile
;   Author: Danilo
;   Date  : 07.01.2004

; Need PB 3.80+ (fixed PB3.80 compiler)!!
Procedure CatchPictureFile(image,adr,dwFileSize)
  ; 
  ; catch
  ;        BMP, GIF, JPG, WMF, EMF, ICO 
  ;
  If adr And dwFileSize
    HGLOBAL    = GlobalAlloc_(#GMEM_MOVEABLE, dwFileSize)
    If HGLOBAL 
      pvData = GlobalLock_(HGLOBAL)
      CopyMemory(adr,pvData,dwFileSize)
      GlobalUnlock_(HGLOBAL) 

      If CreateStreamOnHGlobal_(HGLOBAL, #True, @pstm.IStream) = #S_OK 
        If OleLoadPicture_(pstm, dwFileSize, #False,?IID_IPicture, @Pic.IPicture) = #S_OK 

          ; Here we got the IPicture Object 

          Pic\get_Height(@Height) 
          Pic\get_Width(@Width) 
          
          hDC = GetDC_(GetDesktopWindow_()) 
          ScreenPixels_X = GetDeviceCaps_(hDC,#LOGPIXELSX) 
          ScreenPixels_Y = GetDeviceCaps_(hDC,#LOGPIXELSY) 
          ReleaseDC_(GetDesktopWindow_(),hDC) 

          PicHeight = (Height * ScreenPixels_X) / 2540 
          PicWidth  = (Width  * ScreenPixels_Y) / 2540 
          
          result = CreateImage(image,PicWidth,PicHeight) 
          
          If result 
            hDC = StartDrawing(ImageOutput()) 
              Pic\Render(hDC,0,PicHeight,PicWidth,-PicHeight,0,0,Width,Height,0) 
            StopDrawing() 
          EndIf 
          
          Pic\Release() 
        EndIf 
        pstm\Release() 
      EndIf 
    EndIf 
  EndIf 
  ProcedureReturn result 

  DataSection 
    IID_IPicture: 
      Data.l $7BF80980 
      Data.w $BF32,$101A 
      Data.b $8B,$BB,$00,$AA,$00,$30,$0C,$AB 
  EndDataSection 
EndProcedure 

Image = CatchPictureFile(1,?Image_Start,?Image_End-?Image_Start) 
If Image 
  OpenWindow(1,0,0,ImageWidth(),ImageHeight(),#PB_Window_BorderLess|#PB_Window_ScreenCentered,"ImageV!ew") 
  CreateGadgetList(WindowID()) 
  ImageGadget(1,0,0,ImageWidth(),ImageHeight(),Image) 
  
  Repeat 
    Select WaitWindowEvent() 
      Case #PB_Event_CloseWindow : End 
      Case #WM_RBUTTONUP         : End 
      Case #WM_LBUTTONDOWN       : SendMessage_(WindowID(),#WM_NCLBUTTONDOWN, #HTCAPTION,0) 
    EndSelect 
  ForEver 
EndIf 


DataSection
  Image_Start:
    IncludeBinary "my.bmp"
  Image_End:
EndDataSection

Posted: Thu Jan 15, 2004 3:34 am
by El_Choni
The plugin works here. Could you please post the image/s you can´t load? (and specify if you use LoadImage(), CatchImage() or what). Thanks,