|
Check it for what specifically? A detail or three would be nice!
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Maybe this[^] link will get you started in the right direction.
|
|
|
|
|
You cant really since you have no idea just what it does at a functional level, however running it through Microsofts WHQL will tell you whether it is fit or not. You can also enable Verifier on it and select pretty much everything except Low Resource SImulationn.
If it fails these, junk it and tell who wrote it their product is garbage.
|
|
|
|
|
You can use GetFileVersionInfoSize() , GetFileVersionInfo() and VerQueryValue on a driver-file just the same way as a DLL/EXE.
It is a bit complex, but see here for an example.
Gisle V.
# rm -vf /bin/laden
/bin/rm: success
|
|
|
|
|
Dear All,
when its required explicit keyword in constructor? and what is the purpose?
Regards,
Ranjith
|
|
|
|
|
It is used to prevent the constructor to be used for implicit conversion, see explicit (C++)[^] for an example.
0100000101101110011001000111001011101001
|
|
|
|
|
Hey there,
I have the raw image data and now want to convert it to PNG image. How can i do that? The raw image data is stored in a unsigned char *.
I know how to convert it to Bitmap, but have no idea how to convert it to PNG.
Thanks in advance.
|
|
|
|
|
|
Hi,
If you are on the Microsoft Windows operating system and don't mind using the GDI+ library then you could use the Bitmap Class[^] which inherits from the Image Class[^] that has an Image::Save[^] method and can be used for image encoding[^].
Best Wishes,
-David Delaune
|
|
|
|
|
Yes i am using MFC in Visual Studio 2012 IDE.
Does Image Encoding can convert raw image date to PNG format?
I know Image.Save() can save a BMP file in PNG or JPG format, but here the purpose is not convert and save into the hard drive. But i want the PNG formatted data, which can be later used for other purposes.
|
|
|
|
|
Hi,
Don Guy wrote: Does Image Encoding can convert raw image date to PNG format? No
I gave you a link to the Bitmap Class[^]. You should consider using one of these class constructors to generate your Bitmap object.
Bitmap.Bitmap(INT, INT, INT, PixelFormat, BYTE*) constructor[^]
Bitmap.Bitmap(const BITMAPINFO*, VOID*) constructor[^]
Don Guy wrote: I know Image.Save() can save a BMP file in PNG or JPG format, but here the purpose is not convert and save into the hard drive. But i want the PNG formatted data, which can be later used for other purposes.
Great. Since you already know that you can call Image.Save[^] to save to disk. Then surely you would know that you can also save to an in-memory IStream[^]:
Image.Save(IStream*, const CLSID*, const EncoderParameters*) method[^]
Here is an example from one of my personal projects. In this project I am taking screenshots of websites via the Webkit backing store and converting them to PNG image thumbnails and serving them over HTTP. This example reads from a HBITMAP to a Bitmap object then saves as an encoded PNG image into an in-memory IStream.
BYTE * WebKitWnd::GetPNGImageFromBackingStore(UINT& iLength)
{
BYTE *pRet = nullptr;
iLength = 0;
CDC memDC;
memDC.CreateCompatibleDC(NULL);
DIBSECTION ds;
BITMAPINFOHEADER &bmInfo = ds.dsBmih;
if(NULL != m_hBacking && NULL != ::GetObject(m_hBacking, sizeof(ds), &ds))
{
Bitmap bmp(m_hBacking,NULL);
Graphics g(&bmp);
CLSID encoderClsid;
BYTE *png_buffer = nullptr;
if(TRUE == GetEncoderClsid(L"image/png", &encoderClsid))
{
IStream *buffer;
VERIFY_SUCCEEDED(::CreateStreamOnHGlobal(NULL, FALSE, &buffer));
bmp.Save(buffer,&encoderClsid,NULL);
STATSTG statstg;
VERIFY_SUCCEEDED(buffer->Stat(&statstg, STATFLAG_DEFAULT));
ULONG m_bmpBufferSize = (ULONG)statstg.cbSize.LowPart;
BYTE *png_buffer = new(std::nothrow) BYTE[m_bmpBufferSize];
if(png_buffer)
{
LARGE_INTEGER li = {0};
buffer->Seek(li, STREAM_SEEK_SET, NULL);
ULONG m_nRead;
buffer->Read(png_buffer,m_bmpBufferSize, &m_nRead);
pRet = png_buffer;
iLength = m_bmpBufferSize;
buffer->Release();
}
}
}
memDC.DeleteDC();
return pRet;
}
Best Wishes,
-David Delaune
|
|
|
|
|
I get an error @ GetEncoderClsid - Error undefined function call.
So i added the below function i got from MSDN and this throws an exception.
Is GetEncoderClsid a Windows function?
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
ImageCodecInfo* pImageCodecInfo = NULL;
Gdiplus::GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
Gdiplus::GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}
|
|
|
|
|
The exception is being thrown inside file - GdiplusImageCodec.h in fucntion GetImageEncodersSize
It says "Access violation writing to location................"
|
|
|
|
|
Unhandled exception at 0x000000007772E4E4 (ntdll.dll) in My.exe: 0xC0000005: Access violation writing location 0x0000000000000024.
|
|
|
|
|
|
Thanks a lot David Delaune
|
|
|
|
|
I have a application have hte trayIcon with a Close menu, and it needs keep identical with task bar right click menu.
But if a Modal window shows, the application cannot be closed if uses [close] menu on the task bar, so I need to check if a modal window is showing, when user click the close menu on the tray icon.
|
|
|
|
|
I would suggest setting an application wide flag whenever a modal dialog is displayed.
The flag could be set in the WM_INITDIALOG handler.
When the modal dialog is closed, the flag can be reset.
These actions could be repeated for all modal dialogs in the application.
The same flag can then be checked from the tray.
|
|
|
|
|
Hi Superman,
Perhaps this will meet the recursion problem. And this project only use the C++ not MFC, so if there anyways to use the GetTopWindow or GetLastActivePopup to judge if there is a modal window showing?
|
|
|
|
|
Normally from the taskbar close menus you should send only WM_CLOSE to the main window and you should handle the program exit and "exit possible" flag from the WM_CLOSE handler of your main window. I would extend Superman's solution by using a counter instead of a bool, everytime a modal dialog opens increase the counter and everytime a modal dialog closes decrease the counter. If you have a lot of modal dialogs then you could automatize this by inheriting your dialog classes from a common class and you could implement this feature only once for all dialogs in the base class. So it is OK to close the main window only if your dialog counter is zero. Optionally you can grey out the close buttons/menuitems when the counter is nozero.
EDIT: Here is an alternative solution that MAY WORK, I haven't tried it: Usually when at least one modal dialog is active all other windows/dialogs in the background are disabled (with EnableWindow()[^]). So if the main window is disabled we can suspect that it is disabled because of a modal window (unless you are disabling it manually that I doubt). In this case you could use the IsWindowEnabled()[^] function on the main window to detect whether it is enabled or disabled. So all you have to do is cancelling the main window close (from your WM_CLOSE handler) if the main window is disabled (plus all you should do from your context menu close command is sending a WM_CLOSE to the main window so your WM_CLOSE handler will handle the main window close command regardless of the source of the command). CWnd also has an IsWindowEnabled()[^] method besides the winapi IsWindowEnabled().
modified 23-Sep-13 15:33pm.
|
|
|
|
|
|
Hey there
I have a HBITMAP object in my codeand now i want to use CreateFile function to open this object and then read it's contents.
How can i do that? Or is there another function to open and read the contents of the HBITMAP?
Thanks in advance.
|
|
|
|
|
HBITMAP is a handle to a bitmap object[^] in memory, not a file.
Veni, vidi, abiit domum
|
|
|
|
|
What do you want to do with the contents?
If you want to display the bitmap, you need to first create a device context using CreateDC and then select the HBITMAP into the device context using SelectObject .
You can then use the device context to display the image using the various bitmap functions - Bitmap functions[^]
|
|
|
|
|