saving_20a_20gif_20image
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| saving_20a_20gif_20image [2018/03/31 13:19] – external edit 127.0.0.1 | saving_20a_20gif_20image [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| =====Saving a GIF image===== | =====Saving a GIF image===== | ||
| - | //by Richard Russell, December 2006//\\ \\ The main BBC BASIC for Windows documentation explains how to [[http:// | + | //by Richard Russell, December 2006//\\ \\ The main BBC BASIC for Windows documentation explains how to [[http:// |
| + | |||
| + | <code bb4w> | ||
| bmpfile$ = " | bmpfile$ = " | ||
| SYS " | SYS " | ||
| Line 7: | Line 9: | ||
| bmpfile$ = " | bmpfile$ = " | ||
| SYS " | SYS " | ||
| - | Where **dx%** and **dy%** are the wanted width and height of the image respectively (the scaling quality is not particularly good so for best results you might prefer to scale the image using a third-party program).\\ \\ There are a number of other ways in which you might obtain a bitmap handle, which are outside the scope of this article. You can easily obtain a handle to whatever is displayed in your program' | + | </ |
| + | |||
| + | Where **dx%** and **dy%** are the wanted width and height of the image respectively (the scaling quality is not particularly good so for best results you might prefer to scale the image using a third-party program).\\ \\ There are a number of other ways in which you might obtain a bitmap handle, which are outside the scope of this article. You can easily obtain a handle to whatever is displayed in your program' | ||
| + | |||
| + | <code bb4w> | ||
| SYS " | SYS " | ||
| - | but this ordinarily returns the //entire// 1920 x 1440 bitmap which is probably not what you want. To save just a region of your program' | + | </ |
| + | |||
| + | but this ordinarily returns the //entire// 1920 x 1440 bitmap which is probably not what you want. To save just a region of your program' | ||
| + | |||
| + | <code bb4w> | ||
| bmpfile$ = " | bmpfile$ = " | ||
| bmpfile% = OPENIN(bmpfile$) | bmpfile% = OPENIN(bmpfile$) | ||
| Line 24: | Line 34: | ||
| vbits%!I% = bmpfile%!(I%+O%) | vbits%!I% = bmpfile%!(I%+O%) | ||
| NEXT | NEXT | ||
| - | Once you've got a handle to the bitmap you simply save it as a GIF file as follows:\\ \\ | + | </ |
| + | |||
| + | Once you've got a handle to the bitmap you simply save it as a GIF file as follows: | ||
| + | |||
| + | <code bb4w> | ||
| PROCsavegif(hbitmap%, | PROCsavegif(hbitmap%, | ||
| - | Here **filename$** is the name of the GIF file to create.\\ \\ One you've saved the file you should delete the bitmap handle:\\ \\ | + | </ |
| + | |||
| + | Here **filename$** is the name of the GIF file to create.\\ \\ One you've saved the file you should delete the bitmap handle: | ||
| + | |||
| + | <code bb4w> | ||
| SYS " | SYS " | ||
| - | Finally, here's the code for **PROCsavegif** itself:\\ \\ | + | </ |
| + | |||
| + | Finally, here's the code for **PROCsavegif** itself: | ||
| + | |||
| + | <code bb4w> | ||
| DEF PROCsavegif(hbitmap%, | DEF PROCsavegif(hbitmap%, | ||
| LOCAL gdiplus%, ole32% | LOCAL gdiplus%, ole32% | ||
| Line 74: | Line 96: | ||
| ENDPROC | ENDPROC | ||
| - | \\ | + | </ |
| + | |||
| + | If, instead of a bitmap **handle**, you have a bitmap (DIB) stored in memory you can use this alternative routine: | ||
| + | |||
| + | <code bb4w> | ||
| DEF PROCsavegifdib(dib%, | DEF PROCsavegifdib(dib%, | ||
| LOCAL gdiplus%, ole32% | LOCAL gdiplus%, ole32% | ||
| Line 120: | Line 146: | ||
| ENDPROC | ENDPROC | ||
| - | \\ | + | </ |
| + | |||
| + | You would call it as follows: | ||
| + | |||
| + | <code bb4w> | ||
| PROCsavegifdib(dibits%, | PROCsavegifdib(dibits%, | ||
| + | </ | ||
| + | |||
| where **dibits%** is the address of the bitmap data and **bmi{}** is a BITMAPINFO structure containing the dimensions etc. and (optionally) colour palette for the bitmap. | where **dibits%** is the address of the bitmap data and **bmi{}** is a BITMAPINFO structure containing the dimensions etc. and (optionally) colour palette for the bitmap. | ||
saving_20a_20gif_20image.1522502378.txt.gz · Last modified: 2024/01/05 00:16 (external edit)