|
li zhiyuan wrote: ...anyone can list what i can check step by step for this issue?
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am displaying image using gdi+ using DrawImage() method . but I cannot set the opacity of the drawn image,
like AlphaBlend() method of the win32 api.
Trioum
|
|
|
|
|
use GDI+ ColorMatrix structure
|
|
|
|
|
I searched on MSDN and googling lot but could not find the piece of code
so that I can draw image with opacity between 0-255. can you help me with
some piece of code.
Trioum
|
|
|
|
|
You can use GDI (AlphaBlend) to display the image instead of GDI+ or you
could convert the image to an ARGB format and use per-pixel alpha in GDI+.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
after lot of googling I could not find the code using gdi+ for alpha .
can you send me some piece of code with gdi +
Trioum
|
|
|
|
|
Hello everyone,
Auto_ptr is convenient because of it saves our work and provides a framework to auto-management life cycle to reduce potential resource leak.
But why do we sometimes need to call release method on auto_ptr to go back to the style of manual management? Remember, when we call release, we need to delete the object instance manually later.
(here is a sample I modified from MSDN auto_ptr sample code)
class Int
{
public:
Int( int i )
{
x = i;
cout << "Constructing " << ( void* )this << " Value: " << x << endl;
};
~Int( ) {
cout << "Destructing " << ( void* )this << " Value: " << x << endl;
};
int x;
};
int main( )
{
auto_ptr<int> pi ( new Int( 5 ) );
Int* pi3 = pi.release ();
delete pi3;
}
</int>
thanks in advance,
George
|
|
|
|
|
George_George wrote: But why do we sometimes need to call release method on auto_ptr to go back to the style of manual management?
it is the flexibility to disassociate the memory object without deleting, and that is the reason we need to handle its deletion,
a simple use case of producer and consumer. just for example
void producer::loop()
{
while (!exitEvent())
{
auto_ptr<data> pi(produce());
if (waitForExitorConsumeEvent())
{
if(ConsumeEvent())
{
consumer.consume(pi.release())
}
}
}
}
modified on Tuesday, February 19, 2008 7:42 AM
|
|
|
|
|
Thanks Rajkumar,
Cool and wonderful sample!
But I am confused about one line of your code, this line,
auto_ptr<data> pi(produce());
</data>
My question is, auto_ptr should be used with object allocated on heap (can not be on stack), right? So, the function produce returns an object on heap?
regards,
George
|
|
|
|
|
George_George wrote: So, the function produce returns an object on heap?
yes, offcourse
data *Produce(); lets say.
data *Produce()
{
data * pData = new data();
.... fill the pData
return pData;
}
|
|
|
|
|
Thanks Rajkumar,
Your clarification is clear. My question is answered.
regards,
George
|
|
|
|
|
As a side note, you are aware of the pitfalls of std::auto_ptr regarding to ownership, and of the replacements offered by e.g. boost.org ?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks jhwurmbach,
1. It is appreciated if you could let me know what pitfalls do you mean?
2. What replacement do you mean? share_ptr?
regards,
George
|
|
|
|
|
Friends,
In my appln i am using an exported member(static memebr of a clasas) from a dll.
But i am getting a link error on that static member valrible.
In my Dll Project i have set the __EXPORT defenition in the project settings
Im my application i have given lib name in the project settings.
Does any one have any idea. why this happends...?
The dll implemenntation is as follows;
//MyClass.h
#ifdef __EXPORT
#define EXPORT _declspec(dllexport)
#else
#define EXPORT _declspec(dllimport)
#endif
class EXPORT CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int nValue;
};
//MyClass.h.cpp
#include "MyClass.h"
int CMyClass::nValue = 0;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
Does any one have any idea why this happend?????
|
|
|
|
|
Friends,
In my appln i am using an exported member(static memebr of a clasas) from a dll.
But i am getting a link error on that static member valrible.
In my Dll Project i have set the __EXPORT defenition in the project settings
Im my application i have given lib name in the project settings.
Does any one have any idea. why this happends...?
The class implemenntation is as follows;
//MyClass.h
#ifdef __EXPORT
#define EXPORT _declspec(dllexport)
#else
#define EXPORT _declspec(dllimport)
#endif
class EXPORT CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int nValue;
};
//MyClass.h.cpp
#include "MyClass.h"
int CMyClass::nValue = 0;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
Does any one have any idea why this happend?????
|
|
|
|
|
Can you cut and paste the error here please?
Just a stab in the dark, but have you tried:
int EXPORT CMyClass::nValue = 0;
?
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
This is the error message
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
|
|
|
|
|
I already showed you a working sample and suggested the proper settings for your application, please review the latters.
BTW Can you see the DLL exported int with Dependency Walker?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
I think u are speaking abt another thread that i launched day before yesterday.
Unfortunately that thread lost, i do not how that happend.
So i could not see your reply.
Expeting more help on this topic
Thanks
Prasanth
|
|
|
|
|
Prasanth M V wrote: Unfortunately that thread lost, i do not how that happend.
The Lost Thread ^
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have gone though ur help.It seems that we are in the same path.
But there is still error.
Is there anything related with machine configuration?\
I am Win XP Sp2
Or any other library dependency?
Thanks
Prasanth M V
|
|
|
|
|
The following is a working sample:
DLL header
#ifdef CPPDLL_EXPORTS
#define CPPDLL_API __declspec(dllexport)
#else
#define CPPDLL_API __declspec(dllimport)
#endif
class CPPDLL_API CCppDll {
public:
CCppDll(void);
~CCppDll(void);
static int nValue;
};
DLL source
CCppDll::CCppDll()
{
return;
}
CCppDll::~CCppDll()
{
return;
}
int CCppDll::nValue = 0;
Application source
#include "stdafx.h"
#include "..\\..\\CppDLL\\CppDLL\CppDLL.h"
int _tmain(int argc, _TCHAR* argv[])
{
CCppDll::nValue =5;
}
It works fine on my system (VS 2005, Win XP).
Have you checked again your client project settings? What about the little test with Dependency Walker?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi ,
I have just gone through your Dll implementation code.
I think we both moving with same implementation.
But still there is error in my PC.
My Build environment details is as follows:
OS – Win XP SP2
IDE – Microsoft Visual 6.0(c++)
I tested the same implementation in another PC which has the same configuration, but the same error.
Thanks
Prasanth M V
|
|
|
|
|
this can occur if u donot define the nValue in ur DLL, but ur code shows u defined the variable,
I see two possibility,
1) u may be linking to wrong export library, that can happen if u r moving projects, but given fixed path.
2) ur error message shows it is not dllimport, it is normal class declaration,
if dllimport then following can be the error message
error LNK2001: unresolved external symbol "__declspec(dllimport) public: static int CMyClass::nValue" (__imp_?nValue@CMyClass@@2HA)
not this
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
this can happen if ur using different header file, other than that used in DLL project which doesnot have the dllimport keyword
modified on Tuesday, February 19, 2008 7:23 AM
|
|
|
|
|
Hi.
I have 2 web cameras connected to my PC.
capGetDriverDescription retreives:
Microsoft WDM Image Capture (Win32)
The capDlgVideoDisplay macro displays a dialog box in which I can choose between 2 web cameras.
How to switch between web cameras from my code (not using capDlgVideoDisplay macro)?
Or how to enumerate capturing devices and then select one?
Thank you in advance!
TomazZ
|
|
|
|