SafeArrayCreate(Ex) Failure....
-
Hi Folks ;) I finished burning my brain with system-level configuration of my com, and now I get the first "normal" errors. I have a Variant that contains an array of a structure (4 int), and 2 other int, that are rows and columns (of the image I must import) In this piece of code HRESULT Image2Variant (IVA_Image Source, VARIANT *Dest) { SAFEARRAYBOUND sabRGB[6] sabRGB[0].lLBound = 0; sabRGB[0].cElements = Source.columns * Source.rows; sabRGB[1].lLBound = 0; sabRGB[1].cElements = Source.columns * Source.rows; sabRGB[2].lLBound = 0; sabRGB[2].cElements = Source.columns * Source.rows; sabRGB[3].lLBound = 0; sabRGB[3].cElements = Source.columns * Source.rows; sabRGB[4].lLBound = 0; sabRGB[4].cElements = 1 // the only columns value sabRGB[5].lLBound = 0; sabRGB[5].cElements = 1 // the only rows value VariantInit(Dest); Dest->vt = VT_VARIANT | VT_ARRAY; Dest->parray = SafeArrayCreate(Dest->vt, 1, saRGB); .... Dest->parray is NULL, so I think that function fails, but I don't know why... Suggestions? Thanx Morenz
-
Hi Folks ;) I finished burning my brain with system-level configuration of my com, and now I get the first "normal" errors. I have a Variant that contains an array of a structure (4 int), and 2 other int, that are rows and columns (of the image I must import) In this piece of code HRESULT Image2Variant (IVA_Image Source, VARIANT *Dest) { SAFEARRAYBOUND sabRGB[6] sabRGB[0].lLBound = 0; sabRGB[0].cElements = Source.columns * Source.rows; sabRGB[1].lLBound = 0; sabRGB[1].cElements = Source.columns * Source.rows; sabRGB[2].lLBound = 0; sabRGB[2].cElements = Source.columns * Source.rows; sabRGB[3].lLBound = 0; sabRGB[3].cElements = Source.columns * Source.rows; sabRGB[4].lLBound = 0; sabRGB[4].cElements = 1 // the only columns value sabRGB[5].lLBound = 0; sabRGB[5].cElements = 1 // the only rows value VariantInit(Dest); Dest->vt = VT_VARIANT | VT_ARRAY; Dest->parray = SafeArrayCreate(Dest->vt, 1, saRGB); .... Dest->parray is NULL, so I think that function fails, but I don't know why... Suggestions? Thanx Morenz
A suggestion for you on your SafeArray init. I believe that you need to init the vt (first param) with a data type, that is, VT_R4 or something such as that. I am not certain if you are putting in Array addresses in the safearray itself. It looks like you want data values such as floats or integers. I have used several safearrays and my inits always work with a VT_R4 for float instead of your Dest->vt. The documentation states: >> vt The base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal. >> The other suggestion is that this array is for two dimensions ((Source.columns * Source.rows) by 6), is it not? Therefore the second parameter of the SafeArrayCreate should be 2.
-
A suggestion for you on your SafeArray init. I believe that you need to init the vt (first param) with a data type, that is, VT_R4 or something such as that. I am not certain if you are putting in Array addresses in the safearray itself. It looks like you want data values such as floats or integers. I have used several safearrays and my inits always work with a VT_R4 for float instead of your Dest->vt. The documentation states: >> vt The base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal. >> The other suggestion is that this array is for two dimensions ((Source.columns * Source.rows) by 6), is it not? Therefore the second parameter of the SafeArrayCreate should be 2.
First of all, thanx a lot for your reply. I did it work, it was none of the precedent thoughts or ideas we had. It was simply that the cElements record of SAFEARAYBOUND structure had a too big value. I tried with 1000, and it's too big again. It likes 10 ;). Now, if that's the problem, I'm back again at the starting point. I need to pass an array that could be max 1024 rows x 1024 cols, x 4 bytes (almost 4 megabytes). How can I do? Putting it into a file, sending the file and reading it back again serially is not a good trick, because if it's true that time is not a prerequisite, it's true, too, that I cannot make it last a minute to analyze a 1024 x 1024 raster image! Should I serialize it into strings and send 'em in some chunks? How can I do? When will these annoying problems stop, so I can start making a decent debug? :mad: Thanks again Morenz