Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. SafeArrayCreate(Ex) Failure....

SafeArrayCreate(Ex) Failure....

Scheduled Pinned Locked Moved COM
comdata-structuresquestionworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    morenz
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • M 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

      D Offline
      D Offline
      David_Leikis
      wrote on last edited by
      #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.

      M 1 Reply Last reply
      0
      • D David_Leikis

        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.

        M Offline
        M Offline
        morenz
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups