April 25, 2024, 04:30:37 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Slideshow Version 2

Started by GWS, March 03, 2018, 12:52:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

March 03, 2018, 12:52:00 PM Last Edit: March 03, 2018, 01:04:13 PM by GWS
Hi Folks,

Here is the latest version of my original Slideshow program ..
http://www.ionicwind.com/forums/index.php?topic=5840.msg43216#msg43216

I like this little utility - it enlarges images to full screen size - which gives a whole new feel to many old photographs. :)

The original program worked by displaying images at some chosen rate from 5 seconds upwards ..
The user could choose from a selection of time intervals.  This is OK - but I felt the user interface was a bit clunky.. ::)

This version of the program has a default display rate fixed at 5 seconds - but as before, pressing the Space Bar pauses the program, so that a photograph can be looked at for as long as you like.  :)  Pressing the Space Bar again, continues displaying other images.

I think this gives a nicer interface - and the user can now choose from Sequential, Random, or Selected display options.

The 'Selected' option, displays a gallery of 10 (reduced size thumbnails) in 150 x 150 pixel placeholders. If you have more than 10 images in your folder, you can click the 'Show More' button to show the next 10 images - and so on.

Each image has a 'Display' button underneath it.  If you click one of these, the image will be presented at full screen size.  ::)

To the left of this screen is a 'Back' button, which will take you back to the Selection screen.

So you can easily browse through your images in any order you like ..  ;D

I have to say, I find it hard to imagine developing little programs like this one, without good old Creative Basic to hand.  The debug facility alone is worth it's weight in gold when you're trying to discover why your program is not working as you expect.  It's a great piece of software ..  :)

Best wishes, :)

Graham



Tomorrow may be too late ..

GWS

Hi,

I thought I’d make a couple of comments about this program â€" apart from the fact that I find it quite satisfying, and useful. :)

Both are concerned with the remarkable graphics facilities that Creative provides ..

The first thing that surprised me as I was writing the program, relates to handling large numbers of photographs of varying sizes.

One way of programming this would be to have some kind of dynamic image array to pick from.

However, some image data can be up to 1 Mb in size, so if you have a folder with 100 or more pictures in it, this becomes rather a lot of data to have swishing around.

This program uses just one image variable defined as Def im : int.

This one variable is used to load and process the data one image at a time.  Then it gets deleted and is re-used for the next picture, until finally it gets deleted at the end of the program to avoid memory loss.   

I find that amazing â€" that no interference occurs between images when they are displayed.  Quite a tribute to the graphics handling built into Creative, to process all that information using just one integer variable.

The actual image data never moves from the original folder.

Then there are the pictures themselves.  They are all of varying types (bmp and jpg) and sizes.

Yet Creative, with just one instruction such as:-

SHOWIMAGE w2, im, @IMGSCALABLE, xpos, ypos , iW, iH

is able to display them at any size you choose.

If your eyesight is good enough, you could populate the screen with images just ¼ inch square  :o, or, as is the purpose of this program, fill the screen with just one image.

All this is possible with no distortion of the images and very little pixelation, since the program prevents scaling to more than double the original size.

I suppose its down to the way Creative encapsulates some powerful Windows API graphics routines into the LoadImage and ShowImage instructions.

However its done, the results are pretty impressive I think, and I’m quite pleased with how the project turned out.

all the best, :)

Graham



Tomorrow may be too late ..

Brian

Graham,

Just had a go with the Slideshow program - very nice. I picked a folder to view some pics. No problems. I then decided to choose another folder, and pressed ESC, thinking it would go back to the main screen. It exited the program

Would be nice if it went back to the main screen, so you can start again or, indeed, exit the program

Brian

GWS

Hi Brian,

Glad you liked it. :)

At the moment, when you browse for a folder, and begin viewing, either ESC or Q will exit the program.

It wouldn't be difficult to add a 'Restart' button on each page to go back to the first screen, although it may be just as easy to restart the program. 

My expert adviser, daughter Kim  :) is coming tomorrow - I'll see what she thinks ..  ;D

All the best, :)

Graham
Tomorrow may be too late ..

Andy

March 06, 2018, 06:49:12 AM #4 Last Edit: March 06, 2018, 06:54:19 AM by Andy
Graham,

I'd love to see it, but Avast complains about it (the exe file) - I'm sure they are wrong.

After turning off Avast, running it and browsing to some photos I got multiple error messages between photos:

JFIF APP0 not found.

So in total I had to manually close 7 message boxes.

Any ideas?

Andy.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Forgot to mention that I had the same error as Andy, while in gallery mode, but it let me carry on

Brian

GWS

March 06, 2018, 09:28:49 AM #6 Last Edit: March 06, 2018, 08:06:00 PM by GWS
Hi guys,

Yes I know that problem is a nuisance - not a lot I can do about it.

You need to read the discussion on the first version I wrote, that's the link up above.

It's to do with EXIF/IPTC data that gets recorded in digital photos these days.

I've been through those in my saved photos which give the 'JFIF APP0 not found' message.

This extra data has the effect of screwing up the jpg file format, making it very difficult to locate the height and width information.  Some of it is also camera manufacturer specific just to make it more awkward.

For new photos, it's best to not store the EXif data if your camera gives you that option.

For older photos, I read them into either Microsoft Photo Editor (if you still have that very useful program), or Photoshop.  Then just save them again without doing anything else - and the EXif data will be gone, and so will the file processing problem.

I think it probable that many other photo processing programs will be able to remove the EXif stuff as well.

Also, you can use Windows Explorer to get rid of this snooper data.  Right click on the photo and go to Properties.  Then in Details, you will see an option at the bottom ' Remove Properties and Personal Information'.  That hopefully will clear the EXIF data and all will be well.

[Edit: No good  :( .. I've tried the Web advice to use Explorer.  It creates a copy of the image with the data supposedly removed, but it still doesn't work].

So the problem is with the jpg photo files.  Maybe the Slideshow program could do a cleverer job of decoding the complex data, but I haven't found such a method yet.

Best wishes, :)

Graham
Tomorrow may be too late ..

jalih

Quote from: GWS on March 06, 2018, 09:28:49 AM
So the problem is with the jpg photo files.  Maybe the Slideshow program could do a cleverer job of decoding the complex data, but I haven't found such a method yet.

You could use gdi+ and let Image and Graphics classes handle everything.

GWS

March 07, 2018, 01:07:06 AM #8 Last Edit: March 07, 2018, 01:16:32 AM by GWS
How about a short example program using GDI+ to read a jpg and display it ?

Remember, this is Creative Basic - not IWB or Aurora ..  :)

all the best,

Graham
Tomorrow may be too late ..

jalih

Quote from: GWS on March 07, 2018, 01:07:06 AM
How about a short example program using GDI+ to read a jpg and display it ?

Remember, this is Creative Basic - not IWB or Aurora .. 

If Creative Basic can call functions inside external dll, there should be no problems.

With IWB you could define interfaces to make things a little bit easier. Luckily we don't need to use a lot of stuff from gdi+, so we can use flat api instead.

I have some MiniBasic code with just few lines of code, that you should be able to adapt for Creative Basic. I will post some code later today when I get back home.

GWS

Thanks, that will be interesting  :)

Here's my quick test of a Window reading a jpg and displaying it, using just built-in commands.

A bit of a cheat since I've fixed the height and width to appropriate values - but I could have used my image routine at the expense of simplicity.

best wishes, :)

Graham
Tomorrow may be too late ..

jalih

March 07, 2018, 08:24:30 AM #11 Last Edit: March 07, 2018, 11:07:48 AM by jalih
Quote from: GWS on March 07, 2018, 03:10:42 AM
Thanks, that will be interesting  :)

Here is the story:

On Silverfrost FTN95 Fortran compiler forums there were discussion, how hard and big undertaking it would be to add support for modern image formats. Maybe not too hard I thought, and wrote the following test code in MiniBASIC:


##NOCONSOLE
##MAKEDLL
##USES "gdiplus.lib"

type GdiplusStartupInput
    int GdiplusVersion
    int DebugEventCallback
    int SuppressBackgroundThread
    int SuppressExternalCodecs
endtype

@API GdiplusStartup(pointer pToken, pointer GdiplusStartupInput, int GdiplusStartupOutput),int
@API GdiplusShutdown(int token)
@API GdipCreateFromHDC(uint hDC, pointer pGraphics),int
@API GdipDeleteGraphics(int Graphics),int
@API GdipCreateBitmapFromGdiDib(pointer GdiBitmapInfo, pointer gdiBitmapData, pointer pBitmap),int
@API GdipLoadImageFromFile(wstring filename, pointer pImage),int
@API GdipSaveImageToFile(pointer GpImage, wstring filename, pointer clsidEncoder, pointer encoderParams),int
@API GdipDrawImageI(pointer pGraphics, pointer pImage, int x, int y),int
@API GdipDrawImageRectI(pointer pGraphics, pointer pImage, int x, int y, int w, int h),int
@API GdipDisposeImage(int image)
@API GdipGetImageWidth(pointer pImage,uint *width),int
@API GdipGetImageHeight(pointer pImage,uint *height),int


export import_image
func import_image(uint hDC, string filename, int x, int y)
    int result
    uint w, h
    pointer pImage
    pointer pToken
    pointer pGraphics
    GdiplusStartupInput gsi

    gsi.GdiplusVersion = 1
    gsi.DebugEventCallback = NULL
    gsi.SuppressBackgroundThread = FALSE
    gsi.SuppressExternalCodecs = FALSE
    GdiplusStartup(&pToken,gsi,NULL)

    result=GdipLoadImageFromFile(a2w(filename),&pImage)
    GdipGetImageWidth(pImage,&w)
    GdipGetImageHeight(pImage,&h)
    result=GdipCreateFromHDC(hDC,&pGraphics)
    GdipDrawImageRectI(pGraphics,pImage,x,y,w,h)

    GdipDisposeImage(pImage)
    GdipDeleteGraphics(pGraphics)
    GdiplusShutdown(pToken)
endf


export import_imageRect
func import_imageRect(uint hDC, string filename, int x, int y, int w, int h)
    int result
    pointer pImage
    pointer pToken
    pointer pGraphics
    GdiplusStartupInput gsi

    gsi.GdiplusVersion = 1
    gsi.DebugEventCallback = NULL
    gsi.SuppressBackgroundThread = FALSE
    gsi.SuppressExternalCodecs = FALSE
    GdiplusStartup(&pToken,gsi,NULL)

    result=GdipLoadImageFromFile(a2w(filename),&pImage)
    result=GdipCreateFromHDC(hDC,&pGraphics)
    GdipDrawImageRectI(pGraphics,pImage,x,y,w,h)

    GdipDisposeImage(pImage)
    GdipDeleteGraphics(pGraphics)
    GdiplusShutdown(pToken)
endf


Compiled and linked as DLL.

Next, I wrote the following Fortran code for testing purposes:


WINAPP
  INCLUDE <windows.ins>
  STDCALL import_image 'import_image' (VAL, INSTRING, VAL, VAL)
  STDCALL import_imageRect 'import_imageRect' (VAL, INSTRING, VAL, VAL, VAL, VAL)

  integer my_dc
  character (len=20) :: fname

  fname ='testi.png'

  my_dc=get_bitmap_dc@(300,400)
  call import_image(my_dc,fname,0,0)
  i=winio@('%dw %bt[OK]',my_dc)
  call release_bitmap_dc@(my_dc)
END


Attached is the result when program ran.

I never got any feedback on the forums, but needless to say the next release of the compiler supported GDI+ for handling images.

GWS

Hi,

I'm trying a slightly different approach to avoid the error messages.

I also found that if you get a file that has this EXif problem with the 'JFIF APP0 not found' messagebox, you can load the image into Windows Paint - and just save it again as a jpeg image over the top of itself.  The picture will then load correctly.

Presumably Paint writes a 'proper' jpg file. ::)

best wishes, :)

Graham
Tomorrow may be too late ..

GWS

Hi folks,

OK, I've modified the program to provide 'Back' buttons as suggested by Brian  ;D
These will take you back to previous screens.  A useful improvement I think Brian - thanks for the idea.

I've also modified the jpeg problem section - so that if an image can not be decoded to obtain the Width and Height, the program now defaults to 1000 x 750 pixels.  Some distortion may occur, but at least you can see which image is a non-standard jpg.  You can then correct the problem by loading the image into Windows Paint - and saving it again as a valid jpeg.

The error Messagebox is also simplified, and shows the full path of the problem jpeg in it's title bar.

I hope I haven't broken anything else in making these changes - it seems to be working OK on my test picture folders.

all the best, :)

Graham



Tomorrow may be too late ..