[SOLVED] Error in catching image

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

[SOLVED] Error in catching image

Post by SkyManager »

I have tested the following codes in PB 5.7 (Windows 10, 64 bits)

Code: Select all

DataSection
    Config:
    IncludeBinary "A:/config.bmp"
EndDataSection
Global IconCfg = CatchImage(100, ?Config)
Debug "IconCfg = " + Str(IconCfg)
Global ImgCfg = ImageID(IconCfg)  ;<------- Error reports
Error reports for image not initialized
I have no idea what that means.
Also, the IconCfg sometimes reports a negative value, is that correct or mistake?

Could anybody help me out??
Last edited by SkyManager on Thu Aug 08, 2019 6:17 am, edited 1 time in total.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4996
Joined: Sun Apr 12, 2009 6:27 am

Re: Error in catching image

Post by RASHAD »

Hi
IconCfg is the handle of the image
100 is the image ID

Code: Select all

IconCfg = ImageID(100)
Egypt my love
Little John
Addict
Addict
Posts: 4807
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Error in catching image

Post by Little John »

@SkyManager:
See Handles and Numbers in the Reference Manual.
User avatar
Demivec
Addict
Addict
Posts: 4282
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Error in catching image

Post by Demivec »

Here is the application of the previous replies with respect to your code sample:

Code: Select all

DataSection
    Config:
    IncludeBinary "A:/config.bmp"
EndDataSection
Global IconCfg = CatchImage(100, ?Config) ;IconCfg = resulting image handle of image #100 if succesful
Debug "IconCfg = " + Str(IconCfg) ;and =0 if CatchImage() fails.
;Global ImgCfg = ImageID(IconCfg)  ;<------- Error reports,  incorrect usage see below
Global ImgCfg = IconCfg ;or ImgCfg = ImageID(100) ; valid only if CatchImage() was successful
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Re: Error in catching image

Post by SkyManager »

Thanks a lot.
I confuse about the handle and image id
Mohawk70
Enthusiast
Enthusiast
Posts: 404
Joined: Thu May 11, 2006 1:04 am
Location: Florida, USA

Re: Error in catching image

Post by Mohawk70 »

SkyManager wrote:I have tested the following codes in PB 5.7 (Windows 10, 64 bits)

Code: Select all

DataSection
    Config:
    IncludeBinary "A:/config.bmp"
EndDataSection
Global IconCfg = CatchImage(100, ?Config)
Debug "IconCfg = " + Str(IconCfg)
Global ImgCfg = ImageID(IconCfg)  ;<------- Error reports
Error reports for image not initialized
I have no idea what that means.
Also, the IconCfg sometimes reports a negative value, is that correct or mistake?

Could anybody help me out??

"A:/config.bmp" --> "A:\config.bmp" for Windows


Sent from my SM-N960U using Tapatalk
HP Z800 Workstation
CPU : Dual Xeon 5690 3.46GHz
RAM : 192GB RAM
GPU : NVIDIA QUADRO P5000 16GB
Post Reply