OK here is my code, this widget has 2 properties:
fileName -- set this to a valid image file
processParamters -- ignore this, (works as well as can be expected at this point)
If you set the fileName of this widget to a valid "*.png" file the error stops (obviously because the variable is full of valid data)
in the code I have commented my attempts to initialise the variable mProcessedImage. The compiler throws error with:
Code: Select all
variable mProcessedImage is optional Image
no matter where I put it.
A call to my own setter with an emtpy string
has no effect.
the code looks lousy but hey ho
Code: Select all
widget community.livecode.nmallan.imageProcess
use com.livecode.canvas
use com.livecode.widget
metadata title is "Image Process"
metadata author is "Neil Allan"
metadata version is "1.0.0"
property fileName get mImageFile set setImageFile
property processParameters get getProcessParameters set setProcessParameters
private variable mImageFile as String -- image file name
private variable mProcessParameters as List -- process parameters
private variable mOriginalImage as Image -- used to process data
private variable mProcessedImage as Image -- this will be drawn to canvas
private variable mImageData as Data -- the raw bytes ARGB or RGBA to process
--variable mProcessedImage is optional Image -- ***attempt to stop error***
public handler OnLoad()
--variable mProcessedImage is optional Image -- ***attempt to stop error***
--setImageFile(the empty string) -- ***attempt to stop error****
end handler
public handler OnCreate()
-- variable mProcessedImage is optional Image -- *** attempt to stop error ***
-- setImageFile(the empty string) -- ***attempt to stop error***
end handler
public handler OnPaint()
-- variable mProcessedImage is optional Image -- ***attempt to stop error***
if mProcessedImage is defined then
draw mProcessedImage into rectangle [0,0,my width,my height] of this canvas
end if
end handler
private handler setImageFile(in pImageFile as String) as undefined
-- set image file and reset process parameters
get setProcessParameters("0,0,0,0,0,0,0,0,0")
put pImageFile into mImageFile
put image from file mImageFile into mOriginalImage
put mOriginalImage into mProcessedImage
put the pixels of mOriginalImage into mImageData -- ARGB/RGBA data to process
redraw all
end handler
private handler setProcessParameters(in pParameters as String) as undefined
split pParameters by ","
put the result into mProcessParameters
-- the mojo will go here
end handler
private handler getProcessParameters() as String
combine mProcessParameters with ","
return the result
end handler
end widget