New Image plugin available for beta-testing

Developed or developing a new product in PureBasic? Tell the world about it.
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

New Image plugin available for beta-testing

Post 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.
El_Choni
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

Hi,

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

Regards, benny!
Fred
Administrator
Administrator
Posts: 18154
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Works perfectly on Windows 2000. Very nice work ! So much formats for a such small size 8).
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

Works just fine on W2K and XP pro
Tested JPG's and GIF's
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Yeah it works great on win 98 se too :D
and you gotta love the size of the exe :mrgreen:

Regards
Henrik
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

@El_Choni

As usuall, you are a genius!!

Works excellent here in XP.
ARGENTINA WORLD CHAMPION
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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,
El_Choni
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post 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!].
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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.
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post 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...
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Post by Guimauve »

If possible the Zsoft PaintBrush *.pcx image format.

This can be very useful to create images conversion program.


Best Regards

Guimauve
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post 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.
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post 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]
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post 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
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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,
El_Choni
Post Reply