# BBC BASIC Programmers' Reference

### Site Tools

sending_20image_20files_20to_20the_20printer

# Differences

This shows you the differences between two versions of the page.

 sending_20image_20files_20to_20the_20printer [2018/03/31 13:19]127.0.0.1 external edit sending_20image_20files_20to_20the_20printer [2018/04/13 19:56] (current)richardrussell Added syntax highlighting 2018/04/13 19:56 richardrussell Added syntax highlighting2018/03/31 13:19 external edit 2018/04/13 19:56 richardrussell Added syntax highlighting2018/03/31 13:19 external edit Line 3: Line 3: //by Richard Russell, May 2006, updated November 2010 and January 2012//\\ \\  BBC BASIC for Windows provides the ***DISPLAY** command to display an image contained in a Windows Bitmap (.BMP) file on the screen, but there is no equivalent command for sending the file to the printer. You can of course first display it on the screen and then transfer it to the printer using ***HARDCOPY**,​ but the quality of the resulting printout is then limited by the resolution of the screen.\\ \\ //by Richard Russell, May 2006, updated November 2010 and January 2012//\\ \\  BBC BASIC for Windows provides the ***DISPLAY** command to display an image contained in a Windows Bitmap (.BMP) file on the screen, but there is no equivalent command for sending the file to the printer. You can of course first display it on the screen and then transfer it to the printer using ***HARDCOPY**,​ but the quality of the resulting printout is then limited by the resolution of the screen.\\ \\ ==== BMP images ==== ==== BMP images ==== - \\  The program below allows you to send a **BMP** file to the printer. Although in this example nothing else is printed, you can if you wish output text or other images to the same page before finally printing it.\\ \\ + \\  The program below allows you to send a **BMP** file to the printer. Although in this example nothing else is printed, you can if you wish output text or other images to the same page before finally printing it. + + bmp\$ = "​C:​\Windows\Web\Wallpaper\Bliss.bmp"​ bmp\$ = "​C:​\Windows\Web\Wallpaper\Bliss.bmp"​ VDU 2,1,32 VDU 2,1,32 Line 24: Line 26: SYS "​GlobalFree",​ A% SYS "​GlobalFree",​ A% ENDPROC ENDPROC + ​ + The four numeric parameters to "​PROCprintbmp"​ are the position (horizontal,​ vertical) and size (width, height) respectively of the image on the paper, in __inches__, measured from the top left-hand corner.\\ \\ The four numeric parameters to "​PROCprintbmp"​ are the position (horizontal,​ vertical) and size (width, height) respectively of the image on the paper, in __inches__, measured from the top left-hand corner.\\ \\ ==== GIF or JPEG images ==== ==== GIF or JPEG images ==== - \\  If you want to print a **GIF** or **JPEG** file you can use the code below:\\ \\ + \\  If you want to print a **GIF** or **JPEG** file you can use the code below: + + pic\$ = "​C:​\Windows\Web\Wallpaper\Azul.jpg"​ pic\$ = "​C:​\Windows\Web\Wallpaper\Azul.jpg"​ VDU 2,1,32 VDU 2,1,32 Line 60: Line 66: SYS !(!gpp%+8), gpp% SYS !(!gpp%+8), gpp% ENDPROC ENDPROC + ​ + The parameters for "​PROCprintgifjpeg"​ are as described for "​PROCprintbmp"​ above. Note that it is important to include the //drive letter// in the file specification.\\ \\ "​PROCprintgifjpeg"​ will in fact print **BMP** files as well, but "​PROCprintbmp"​ is simpler if that's all you need to do.\\ \\ The parameters for "​PROCprintgifjpeg"​ are as described for "​PROCprintbmp"​ above. Note that it is important to include the //drive letter// in the file specification.\\ \\ "​PROCprintgifjpeg"​ will in fact print **BMP** files as well, but "​PROCprintbmp"​ is simpler if that's all you need to do.\\ \\ ==== PNG or TIFF images ==== ==== PNG or TIFF images ==== - \\  If you want to print a **PNG** or **TIFF** file you can use the code below:\\ \\ + \\  If you want to print a **PNG** or **TIFF** file you can use the code below: + +  ​ pic\$ = "​C:​\WINDOWS\ServicePackFiles\i386\news.png"​ pic\$ = "​C:​\WINDOWS\ServicePackFiles\i386\news.png"​ VDU 2,1,32 VDU 2,1,32 Line 118: Line 128: SYS "​FreeLibrary",​ gdip% SYS "​FreeLibrary",​ gdip% ENDPROC ENDPROC + ​ + The parameters for "​PROCprintpngtiff"​ are as described for "​PROCprintbmp"​ above.\\ \\ "​PROCprintpngtiff"​ will in fact print **BMP**, **GIF** and **JPEG** files as well, and may give better quality results. 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 for "​PROCprintpngtiff"​ are as described for "​PROCprintbmp"​ above.\\ \\ "​PROCprintpngtiff"​ will in fact print **BMP**, **GIF** and **JPEG** files as well, and may give better quality results. 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.