|
|
PPC=> Pocket PC based on WinCE
Any suggestion is useful!! Thanks!!
|
|
|
|
|
Hi, I'm tryning to get an image of a webcam and apply it into an openGL texture.
I'm initializing the window with capCreateCaptureWindow
connect to the webcam with capDriverConnect
Then I use the following code to get an HBITMAP.
capGrabFrame
capEditCopy(hWndCam)
OpenClipboard(hWndCam)
hbitmap = (HBITMAP)GetClipboardData(CF_BITMAP)
How do I get a pointer to the data to be able to feed my glTexImage2D
|
|
|
|
|
I think ::GetBitmapBits can solve your problem .
|
|
|
|
|
thanks, I forgot to tell, I'm using it with Qt and I can't mix it with MFC. Is there any gdi solution?
|
|
|
|
|
GetBitmapBits is API that used in gdi .
It's declaration is :
WINGDIAPI LONG WINAPI GetBitmapBits( IN HBITMAP, IN LONG, OUT LPVOID);
|
|
|
|
|
thanks A_Fa. I tried and my buffer is always empty. The microsoft documentation recommends using GetDIBits, but I get the same result. Do I have to set some HDC or something?
|
|
|
|
|
the MSDN description:
hIconSm: Handle to a small icon that is associated with the window class
hIcon: Handle to the class icon.
But I still confused!
when I creat a window "WNDCLASSEX wc", I could always only see the icon load by the wc.hIconSm when excuting, where to find the big icon load by wc.hIcon?
|
|
|
|
|
hIcon is the large icon (32 x 32) that you can see when hitting Alt+Tab for instance. hIconSm (16 x 16) is shown in the taskbar/tray and in the titlebar of the window.
|
|
|
|
|
|
And see here[^] maybe it is some helpful to you
|
|
|
|
|
Hi guys!
I'm using CStdioFile to read a text file that also may contain some binary data. Problem is, sometimes I hit EOF even though its not the case (e.g. CStdioFile::ReadString returns FALSE but there's still data to be read), possibly because of the binary data in the text file that may contain a EOF char.
Any idea how to solve this? Or do I have to resort to using CFile in binary mode and interpret the text myself?
Thanks
|
|
|
|
|
Tanzim Husain wrote: Or do I have to resort to using CFile in binary mode and interpret the text myself?
umm yeah... since there is binary data in the file it is "by definition" NOT a Text File.
|
|
|
|
|
Hi,
I'm having some problems with DLLs and templates.
The thing is that I have found almost no info on the web, specially about warning C4251 (there's an article, but it doesn't
answer the question I have). The thing is, I have these modules:
A.dll
B.dll (Uses A.dll)
C.dll (Uses A.dll and B.dll)
D.lib (A static library that uses A.dll and C.dll)
E.exe, the executable (uses A and D)
I have a template in A. The thing is that I have found the warning C4251 when I was compiling the template in A, so I instantiated
the whole template and exported it (and dllimported when I was compiling a module other than A (all of this in the header
file, where the template is defined)). An error
arises when I'm linking E.exe, saying that I have duplicate symbols: the member functions of the template in A. The paradox here
is that if I clean all the explicit instantiations of the template and the dllexports/dllimports everything works fine! (It gives me
the C4251 warning when compiling, but it works fine). My questions are: is it necessary to explicitly instatiate the whole template,
, export it and import it when compiling other module? Or is it enough to leave an instantiation per translation unit, given that the dlls and exes are compiled
with the same compiler flags? In this case, what happens with static variables? Is the linker clever enough to use the same static
variable for the different instatiations?
any hint will be very appreciated
Thanks,
Federico
|
|
|
|
|
Because of the nature of templates, you can't put them in DLLs to be exported. Templates are placeholders. For example, when you write vector<MyClass> myVector; the compiler sees it and creates that vector. The vector of MyClass objects is then a specific type. When you just have the template definition, there is no type associated with it yet.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Of course, you're right; but in A I'm using the template as a member of a class thats exported, so the template (at least some of its method) are instantiated in A.dll
This template is also used in E.exe and in B.dll. I think that the question in the original mail is still valid...
|
|
|
|
|
Sorry, I misunderstood your question. While I don't like using this solution much, you might end up having to use #pragma warning(disable...) for that warning.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
You have two solutions:
1) Use the pimpl idiom
2) Use the Microsoft export "hack"
1) By pimpl idiom I mean:
class Class {
struct Pimpl;
Pimpl* m_pimpl;
public:
Class();
~Class();
void SetX(int x);
};
struct Class::Pimpl { int x; }
Class::Class() : m_pimpl(new Pimpl)
{
}
Class::~Class() { delete m_pimpl; }
void Class::SetX(int x) { m_pimpl->x = x; }
That also has the benefit to minimize dependencies between sourcefiles. If you change a data member, only the .cpp containing the Pimpl struct will be recompiled - not all other files which include the header file. More on this idiom can be read here: http://www.gotw.ca/gotw/028.htm[^]
2) This hack is non portable AFAIK. On the other hand, exporting C++ classes is non portable as well, so I guess it's not a problem for you. You can read more about it here: http://support.microsoft.com/kb/q168958/[^]
--
Torn from tomorrow's headlines
|
|
|
|
|
As mentioned, the MS hack is the easiest (though non-portable) way.
e.g.
MyArrayT.h (example template class)
template<class TT> class MyArrayT {...};
MyTempExp.h (not really needed)
typedef MyArrayT<long> MyArrayLong;
MyTempExp.cpp (this is the important part)
template class __declspec(dllexport) MyArrayT<long>;
This will create exports of all methods/data for MyArrayT<long>.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I need source-code or tool to save bitmap buffer to gif file programmatically in VC app, user can specify transparent background color when saving.
which class or tool can help to do that?
|
|
|
|
|
Best option i think you use GDI+!
so first try,
http://www.codeproject.com/vcpp/gdiplus/gdi__and_mfc.asp
for initalize GDI+ then try to search MSDN , encoder & decoder :
for example if you wanna convert bmp to gif this code help you:
<br />
INT GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{<br />
UINT num = 0;
UINT size = 0;
<br />
ImageCodecInfo* pImageCodecInfo = NULL;<br />
<br />
GetImageEncodersSize(&num, &size);<br />
if(size == 0)<br />
return -1;
<br />
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));<br />
if(pImageCodecInfo == NULL)<br />
return -1;
<br />
GetImageEncoders(num, size, pImageCodecInfo);<br />
<br />
for(UINT j = 0; j < num; ++j)<br />
{<br />
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )<br />
{<br />
*pClsid = pImageCodecInfo[j].Clsid;<br />
free(pImageCodecInfo);<br />
return j;
} <br />
}<br />
<br />
free(pImageCodecInfo);<br />
return -1;
<br />
}<br />
<br />
<br />
<br />
CLSID encoderClsid;<br />
Status stat;<br />
Image* image = new Image(L"Bird.bmp");<br />
<br />
GetEncoderClsid(L"image/gif", &encoderClsid);<br />
<br />
stat = image->Save(L"Bird.gif", &encoderClsid, NULL);<br />
<br />
<br />
<br />
delete image;<br />
<br />
|
|
|
|
|
& for transparent background you can search : ImageAttributes class & ColorMatrix class
first create ColorMatrix ! then with SetColorMatrix assign that to instance of ImageAttribute then
draw both of image ! so you can see it transparent background!
|
|
|
|
|
there are many gif related classes on CP, but most of them are for reading gif files. You will find that saving a gif file is very problematic due to the LZW compression and the patenting issues. Must you use a gif format?
Take a look at this article[^]. Its for displaying gif images to a CStatic control. But within the source code are functions for reading a gif directly from the file. You could try reverse engineering it to save instead.
|
|
|
|
|
waldermort wrote: You will find that saving a gif file is very problematic due to the LZW compression and the patenting issues.
all of the relevant LZW patents expired years ago.
|
|
|
|
|
Oh, really? I didn't realize. So I'm guessing there are no reprocussions to loading and saving gif files now?
|
|
|
|