This shows you the differences between two versions of the page.
displaying_20a_20png_20or_20tiff_20image [2018/03/31 13:19] 127.0.0.1 external edit |
displaying_20a_20png_20or_20tiff_20image [2018/04/13 15:30] (current) richardrussell Added syntax highlighting |
||
---|---|---|---|
Line 1: | Line 1: | ||
=====Displaying a PNG or TIFF image===== | =====Displaying a PNG or TIFF image===== | ||
- | //by Richard Russell, November 2010, amended January 2012//\\ \\ BBC BASIC for Windows provides the [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin8.html#display|*DISPLAY]] command to display on the screen an image contained in a **BMP** file, and the main [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#gifjpeg|Help documentation]] describes how to display a **GIF** or **JPEG** image. If you want to display a **PNG** or **TIFF** image you can use the code listed below:\\ \\ | + | //by Richard Russell, November 2010, amended January 2012//\\ \\ BBC BASIC for Windows provides the [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin8.html#display|*DISPLAY]] command to display on the screen an image contained in a **BMP** file, and the main [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#gifjpeg|Help documentation]] describes how to display a **GIF** or **JPEG** image. If you want to display a **PNG** or **TIFF** image you can use the code listed below: |
+ | |||
+ | <code bb4w> | ||
DEF PROCdisplay(pic$, xpos%, ypos%, xsize%, ysize%) | DEF PROCdisplay(pic$, xpos%, ypos%, xsize%, ysize%) | ||
LOCAL tSI{}, pic%, gdip%, image%, ix%, iy%, gfx%, lGDIP% | LOCAL tSI{}, pic%, gdip%, image%, ix%, iy%, gfx%, lGDIP% | ||
Line 50: | Line 52: | ||
SYS "UpdateWindow", @hwnd% | SYS "UpdateWindow", @hwnd% | ||
ENDPROC | ENDPROC | ||
+ | </code> | ||
+ | |||
The parameters are the path/filename of the image file, and the required position and size of the displayed image (measured in pixels from the top left-hand corner of the output window's client area).\\ \\ This code will also display **BMP**, **GIF** and **JPEG** images, and may do so with a better quality than the other methods. However it relies on the presence of the //GDI Plus// library so will work only on Windows XP (or later) or if you have specifically installed **GDIPLUS.DLL** on the target computer. Microsoft permits you to redistribute this file so you can include it with your program if necessary. | The parameters are the path/filename of the image file, and the required position and size of the displayed image (measured in pixels from the top left-hand corner of the output window's client area).\\ \\ This code will also display **BMP**, **GIF** and **JPEG** images, and may do so with a better quality than the other methods. However it relies on the presence of the //GDI Plus// library so will work only on Windows XP (or later) or if you have specifically installed **GDIPLUS.DLL** on the target computer. Microsoft permits you to redistribute this file so you can include it with your program if necessary. |