loading_20a_20gif_20or_20jpeg_20image
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| loading_20a_20gif_20or_20jpeg_20image [2018/03/31 13:19] – external edit 127.0.0.1 | loading_20a_20gif_20or_20jpeg_20image [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| =====Loading a GIF or JPEG image===== | =====Loading a GIF or JPEG image===== | ||
| - | //by Richard Russell, September 2008//\\ \\ The main Help documentation describes how to [[http:// | + | //by Richard Russell, September 2008//\\ \\ The main Help documentation describes how to [[http:// |
| + | |||
| + | <code bb4w> | ||
| DEF FNloadimage(file$, | DEF FNloadimage(file$, | ||
| LOCAL iid{}, bmp{}, ix%, iy%, hbm%, hcopy%, pic%, ole%, olpp%, text% | LOCAL iid{}, bmp{}, ix%, iy%, hbm%, hcopy%, pic%, ole%, olpp%, text% | ||
| Line 42: | Line 44: | ||
| = hcopy% | = hcopy% | ||
| - | The parameters to the function are the filename (or URL) of the image, the required width and height (in pixels) and a flag to indicate whether you want the **aspect ratio** to be preserved or not. Note that a filename must contain the drive name (e.g. **C:**) to distinguish it from an internet URL. The returned value is a **handle** to the image, or zero if the image cannot be found or opened.\\ \\ If the required width and/or height values are supplied as zero then the actual width and/or height of the original image are used. Thus if a non-zero value is supplied for the width and zero is supplied for the height, the image will be scaled horizontally (if required) but not vertically; however if the **preserve aspect ratio** flag is set to TRUE, the then image //will// be scaled vertically to preserve the correct shape.\\ \\ The actual dimensions of the (possibly scaled) image are returned in the second and third parameters, therefore they must be supplied as **variables** rather than as **constants**. Thus if you don't want to scale the image call the function as follows\\ \\ | + | </ |
| + | |||
| + | The parameters to the function are the filename (or URL) of the image, the required width and height (in pixels) and a flag to indicate whether you want the **aspect ratio** to be preserved or not. Note that a filename must contain the drive name (e.g. **C:**) to distinguish it from an internet URL. The returned value is a **handle** to the image, or zero if the image cannot be found or opened.\\ \\ If the required width and/or height values are supplied as zero then the actual width and/or height of the original image are used. Thus if a non-zero value is supplied for the width and zero is supplied for the height, the image will be scaled horizontally (if required) but not vertically; however if the **preserve aspect ratio** flag is set to TRUE, the then image //will// be scaled vertically to preserve the correct shape.\\ \\ The actual dimensions of the (possibly scaled) image are returned in the second and third parameters, therefore they must be supplied as **variables** rather than as **constants**. Thus if you don't want to scale the image call the function as follows | ||
| + | |||
| + | <code bb4w> | ||
| cx% = 0 | cx% = 0 | ||
| cy% = 0 | cy% = 0 | ||
| himage% = FNloadimage(filename$, | himage% = FNloadimage(filename$, | ||
| - | Alternatively if you are not interested in knowing the actual dimensions you can modify the function definition by removing the **RETURN** qualifiers:\\ \\ | + | </ |
| + | |||
| + | Alternatively if you are not interested in knowing the actual dimensions you can modify the function definition by removing the **RETURN** qualifiers: | ||
| + | |||
| + | <code bb4w> | ||
| DEF FNloadimage(file$, | DEF FNloadimage(file$, | ||
| - | With this modification you can supply constant values (e.g. 0) as parameters.\\ \\ When you have completely finished with the image you should delete the handle as follows:\\ \\ | + | </ |
| + | |||
| + | With this modification you can supply constant values (e.g. 0) as parameters.\\ \\ When you have completely finished with the image you should delete the handle as follows: | ||
| + | |||
| + | <code bb4w> | ||
| SYS " | SYS " | ||
| - | To use the **FNloadimage** function to display an image in a **static control** see this [[/ | + | </ |
| + | |||
| + | To use the **FNloadimage** function to display an image in a **static control** see this [[/ | ||
| + | |||
| + | <code bb4w> | ||
| cx% = 0 | cx% = 0 | ||
| cy% = 0 | cy% = 0 | ||
| Line 73: | Line 91: | ||
| SYS " | SYS " | ||
| IF num% <> cy% ERROR 100, " | IF num% <> cy% ERROR 100, " | ||
| - | This provides the image data in ' | + | </ |
| + | |||
| + | This provides the image data in ' | ||
| + | |||
| + | <code bb4w> | ||
| SYS " | SYS " | ||
| IF imagedata% = 0 ERROR 100, " | IF imagedata% = 0 ERROR 100, " | ||
| + | </ | ||
| + | |||
| but in this case don't forget to free the memory later. | but in this case don't forget to free the memory later. | ||
loading_20a_20gif_20or_20jpeg_20image.1522502368.txt.gz · Last modified: 2024/01/05 00:17 (external edit)