Originally posted by: gamester
Why I always got ERROR when calling GetDIBits( ..) ?
the return value of GetDIBits( ..) is always NULL.
Does someone know what's wrong ?
Thanks !!!
Originally posted by: Rudy
How do you display a Bitmap from a menu option using MS-VC++ 6.0/Win32 simple application, no MFC.
It's easy enough to write the code (API) to load and display
the Bitmap, but calling it from a menu option ex:
menu
Bitmap
Where you click on Bitmap and a picture
(Bitmap) displays on the screen.
I have been using switch, case statements, and WM_COMMAND, etc.. but nothing displays.
I have the required parms in the header file and Resource file. I must be leaving something out?
I need sample code.
Any information will be appreciated.
Thanks,
Rudy
Originally posted by: seungho Lee
I drew this symptom as below.
//////////////////////////////////////////////////////
// Convert the bitmap to a DIB
...
Hi! This source is really nice one.
But, During the test this source, I found one problem I can not solve. Below,I wrote the core part of source.
After changing DDB to DIB, I encoded it to jpeg with m_hDIB. The result is below.
Screen is shown with shifted pixel .
123456789 891234567
123456789 891234567
123456789 891234567
123456789 891234567
123456789 891234567
123456789 891234567
Some Right-most bit(89)are seen at the left_most position.
I believe you can understand this probloem.
Please, help me with it.
///////////////////////////////////////////////////
m_rect=CRect(0,0,640,480);
CDib dib;
CSize destSize(640,480);
if(m_hDIB)
{
GlobalFree(m_hDIB);
}
UINT size;
dib.WriteWindowToDIB(m_rect, destSize, m_hDIB, size);
...
..savejpg(..m_hDIB..);
BOOL CDib::WriteWindowToDIB(CRect &rect,
CSize &destSize,
HANDLE &hDIB,
UINT &size)
{
CBitmap bitmap;
CDC memDC,screenDC;
screenDC.CreateDC("DISPLAY",NULL,NULL,NULL);
memDC.CreateCompatibleDC(&screenDC);
bitmap.CreateCompatibleBitmap(&screenDC,
destSize.cx,
destSize.cy,);
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
//capture the screen
memDC.StretchBlt(0,
0,
destSize.cx,
destSize.cy,
&screenDC,
rect.left,
rect.top,
rect.Width(),
rect.Height(),
SRCCOPY);
memDC.SelectObject(pOldBitmap);
hDIB = NULL;
hDIB = DDBToDIB(bitmap, BI_RGB, &pal , size);
screenDC.DeleteDC();
...
}
/////////////////////////////////////////////////////
HANDLE CDib::DDBToDIB(CBitmap &bitmap, DWORD dwCompression, CPalette *pPal, UINT &size)
{
//Everthing is same as your source except one below.
// Initialize the bitmapinfoheader
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = 24;//changed for true color
//bm.bmPlanes * bm.bmBitsPixel;
...
....
}
/////////////////////////////////////////////////////////
Originally posted by: Rehana Rahman
I found it very useful. Now I am stuck with one problem, not sure if there is a solution. That is, when I print the DIB, my graph(chart) is slightly distorded. I compute the "aspect" ratio first, keep printer x value but set y value based on aspect ratio.
POINT ptSize;
ptSize.x = (rect->right - rect->left);
double aspect = (double)srcWidth/(double)srcHeight;
ptSize.y = (long) ((double) ptSize.x / aspect);
Does makeX(), makeY() mentioned as part of DDBToDIB() code have any trick (I noticed that it says the code works fine
with A4 paper)?. If yes, would someone post code to translate. Thanks.
-- rehana
ReplyOriginally posted by: Sekhar
Hello, I need Help!
I included the code of DDBtoDIB() in my project(developed using eVC 3.0).I also included 'wingdi.h' header file .After compilation it's giving GetDIBits() undelcared identifier.What might be the reason?
I just want to copy the bitmap which is on the screen (window to database) on to the database(SQLServer).Is it possible?
Any help in this regard will be appreciated.
Thanking you,
Originally posted by: Rajasekhar
Hello, I need Help!
I couldn't found the code for GetDIBits(), whcih is used in the DDBtoDIB().I want it urgently.Can anybody help me.
I just want to write (window to database) on to the device database(SQLCe).Is it possible?
Any help in this regard will be appreciated.
Thanking you,
ReplyOriginally posted by: young
I have basically same function as DDBToDIB and it seems like it has some resource leak. The debug window does not shows me any memory leak, when I used CRTDBG_MAP_ALLOC, but createDIBSection returns NULL, or GetDIBits failed, about 300 - 400 calls.
Any help, please?
ReplyOriginally posted by: Marcelo
Hi,
i want to know how can I convert an DIB or DDB pointer to a PNG.
Thanks.
Originally posted by: John Ridley
I was using this as a front end to the FreeImage library. FreeImage depends on biClrUsed, which GetDIBits seems to always set to 0. So I added the following lines near the end of the function:
// we'll force this here, because GetDIBits clears these to 0
lpbi->biClrUsed = nColors;
lpbi->biClrImportant = nColors;
Just before the final SelectPalette() call. Worked for me.
ReplyOriginally posted by: Venkatesh
If my image is any type or compressed, this digitize program should convert bmp data to float or int format.
My Email id : krishna_venky@yahoo.com
krishna_venky@indiainfo.com
krishna_venky@rediffmail.com