loading_20a_20png_20or_20tiff_20image
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
loading_20a_20png_20or_20tiff_20image [2018/03/31 13:19] – external edit 127.0.0.1 | loading_20a_20png_20or_20tiff_20image [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
//by Richard Russell, October 2008, revised November 2010 and January 2012//\\ \\ The article [[/ | //by Richard Russell, October 2008, revised November 2010 and January 2012//\\ \\ The article [[/ | ||
==== Method 1 ==== | ==== Method 1 ==== | ||
- | \\ This version is the simpler of the two, but can't cope with very large images and, when scaling is required, the quality is not as good as it might be:\\ | + | \\ This version is the simpler of the two, but can't cope with very large images and, when scaling is required, the quality is not as good as it might be: |
+ | |||
+ | <code bb4w> | ||
DEF FNloadimagegdip(file$, | DEF FNloadimagegdip(file$, | ||
LOCAL tSI{}, bmp{}, ix%, iy%, hbm%, bmp%, hcopy%, gdip%, text%, res%, lGDIP% | LOCAL tSI{}, bmp{}, ix%, iy%, hbm%, bmp%, hcopy%, gdip%, text%, res%, lGDIP% | ||
Line 58: | Line 60: | ||
= hcopy% | = hcopy% | ||
- | \\ | + | </ |
==== Method 2 ==== | ==== Method 2 ==== | ||
- | \\ This version is a little more complicated, | + | \\ This version is a little more complicated, |
+ | |||
+ | <code bb4w> | ||
DEF FNloadimagegdip2(file$, | DEF FNloadimagegdip2(file$, | ||
LOCAL tSI{}, bmi{}, text%, gdip%, image%, ix%, iy%, lGDIP% | LOCAL tSI{}, bmi{}, text%, gdip%, image%, ix%, iy%, lGDIP% | ||
Line 129: | Line 134: | ||
SYS " | SYS " | ||
= hdib% | = hdib% | ||
- | \\ | + | </ |
==== How to use ==== | ==== How to use ==== | ||
- | \\ The parameters to the functions are the filename 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. 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 functions are the filename 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. 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% = FNloadimagegdip2(filename$, | himage% = FNloadimagegdip2(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 FNloadimagegdip2(file$, | DEF FNloadimagegdip2(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 **FNloadimagegdip** function to display an image in a **static control** see this [[/ | To use the **FNloadimagegdip** function to display an image in a **static control** see this [[/ |
loading_20a_20png_20or_20tiff_20image.1522502368.txt.gz · Last modified: 2024/01/05 00:17 (external edit)