BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

tagVariant * question?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
Chris
Guest





PostPosted: Thu Apr 26, 2007 7:25 pm    Post subject: tagVariant * question? Reply with quote



I have an activeX and one of the functions of it is to get a
current Image from a camera.

-------------------------------------------
VARIANT buffer;
long size;

GetCurrentImage( 1, &buffer, &size);
//(0 for jpg:1 for bmp, buffer where image is returned, buffer size)

SAFEARRAY * psa;

psa = buffer.parray;

void * buff2 = psa;
int sz = size;

TMemoryStream* fstream = new TMemoryStream;

fstream->Size = sz;
fstream->Position = 0;
fstream->Write(buff2,sz);
fstream->Position = 0;

fstream->SaveToFile("test.txt");
------------------------------------------------------

I can recieve the buffer from the activeX using the
type 'VARIANT'. However, It seems as if it needs to be
converted in order for me to actually store it as a Bitmap or
JPEG.

Do you have any suggestions on how I can get the correct format from the Variant?

Thanks,

Chris
Back to top
chris
Guest





PostPosted: Thu Apr 26, 2007 7:31 pm    Post subject: more to tagVariant * question? Reply with quote



I forgot to mention that the buffer variable that I was
recieving was listed as type 'tagVariant *' in the
GetCurrentImage function.

GetCurrentImage(int,tagVariant *, long *);
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Apr 26, 2007 9:10 pm    Post subject: Re: tagVariant * question? Reply with quote



"Chris" <nospam (AT) workhard (DOT) com> wrote in message
news:4630b65a$1 (AT) newsgroups (DOT) borland.com...

Quote:
void * buff2 = psa;

That is not the correct way to access the data inside the array. You
need to use the SafeArrayAccessData() function instead:

void *buff2 = NULL;
SafeArrayAccessData(psa, &buff2);
// use buff2 as needed...
SafeArrayUnaccessData(psa);

Quote:
fstream->SaveToFile("test.txt");

If all you are doing is saving the data to a file, then why not use a
TFileStream instead of a TMemoryStream?


Gambit
Back to top
Chris
Guest





PostPosted: Thu Apr 26, 2007 9:55 pm    Post subject: Re: tagVariant * question? Reply with quote

I am going to do a lot more processing to the image after I can receive it. The code I sent was temporary test code that I create in a seperate application until I can learn all the functionality of what I want to do.

I was only semi-familiar with SafeArrays... so what you sent should help.

Thanks again,

Chris
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.