Click here to Skip to main content
15,918,031 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalusing a vector with CComboBox::AddString() in MFC Pin
keegan26-Jun-03 2:52
keegan26-Jun-03 2:52 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
Maximilien26-Jun-03 3:18
Maximilien26-Jun-03 3:18 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
keegan26-Jun-03 3:27
keegan26-Jun-03 3:27 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
Maximilien26-Jun-03 3:35
Maximilien26-Jun-03 3:35 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
keegan26-Jun-03 3:48
keegan26-Jun-03 3:48 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
Shay Harel26-Jun-03 7:57
Shay Harel26-Jun-03 7:57 
GeneralWizard sheet 97 Pin
Member 42425926-Jun-03 2:49
Member 42425926-Jun-03 2:49 
Generalmalloc, free problem ...... Pin
_crs_26-Jun-03 2:44
_crs_26-Jun-03 2:44 
hello,
i have a problem .... a can not free memory ....
i have here 3 pointers iBuffer, jByffer, pDib
at the end of the function I want to free iBuffer and pDib
and it's get me an error when I run the program ... if I remove the "free"
lines it works fine but is not right....
what can I do ??? please if anyone can help .... thank you !


void* DDBToDIB(HBITMAP _desktopBmp, DWORD *bmpsize)
{
BYTE *iBuffer, *iBufferTmp;
int iWidth, iHeight;
void *jBuffer;
int jSize;


BITMAPINFOHEADER head;
void *pDib;
BITMAP bm;

GetObject(_desktopBmp, sizeof(BITMAP), (LPSTR) &bm);
iHeight = bm.bmHeight;
iWidth = bm.bmWidth;

DWORD dwEffWidth = ((((bm.bmBitsPixel * bm.bmWidth) + 31) / 32) * 4);

if (bm.bmBitsPixel == 8) head.biClrUsed = 256;
else head.biClrUsed = 0;
head.biSize = sizeof(BITMAPINFOHEADER);
head.biWidth = bm.bmWidth;
head.biHeight = bm.bmHeight;
head.biPlanes = 1;
head.biBitCount = (WORD)bm.bmBitsPixel;
head.biCompression = BI_RGB;
head.biSizeImage = dwEffWidth * bm.bmHeight;
head.biClrImportant = 0;
head.biXPelsPerMeter = 0;
head.biYPelsPerMeter = 0;

long mypalsize = (head.biClrUsed * sizeof(RGBQUAD));
long mysize = head.biSize + head.biSizeImage + mypalsize;

pDib = malloc(mysize);

BITMAPINFOHEADER* lpbi;
lpbi = (BITMAPINFOHEADER*)(pDib);
*lpbi = head;
iBufferTmp = ((BYTE*)pDib + *(DWORD*)pDib + mypalsize);
HDC dc = GetDC(NULL);
GetDIBits(dc, _desktopBmp, 0, iHeight, iBufferTmp, (LPBITMAPINFO)pDib, DIB_RGB_COLORS);
ReleaseDC(NULL, dc);

iBuffer = (BYTE *)malloc(iHeight * iWidth * 3);

for (int c = iHeight - 1; c >= 0; c--) {
memcpy((BYTE *)iBuffer + ((iHeight - 1 - c) * iWidth * 3),
(BYTE *)iBufferTmp + (c * iWidth * 3), iWidth * 3);
}

for (c = 0; c < iHeight * iWidth; c++) {
iBufferTmp[c * 3] = iBuffer[c * 3 + 2];
iBufferTmp[c * 3 + 1] = iBuffer[c * 3 + 1];
iBufferTmp[c * 3 + 2] = iBuffer[c * 3];
}

jBuffer = (BYTE*)Compress(iBufferTmp, iWidth, iHeight, 3, &jSize, 100);


FILE *dest = fopen("sent.jpg", "wb");
fwrite(jBuffer, jSize, 1, dest);
fclose(dest);

// free(pDib);
// free(iBuffer);

*bmpsize = jSize;
return jBuffer;
}
GeneralRe: malloc, free problem ...... Pin
David Crow26-Jun-03 3:09
David Crow26-Jun-03 3:09 
GeneralRe: malloc, free problem ...... Pin
_crs_26-Jun-03 3:47
_crs_26-Jun-03 3:47 
GeneralRe: malloc, free problem ...... Pin
David Crow26-Jun-03 3:56
David Crow26-Jun-03 3:56 
GeneralSerial Comms Problem Pin
louis26-Jun-03 2:30
louis26-Jun-03 2:30 
GeneralRe: Serial Comms Problem Pin
justin22326-Jun-03 20:13
justin22326-Jun-03 20:13 
Generalcomms config Pin
andyg.10126-Jun-03 2:26
andyg.10126-Jun-03 2:26 
GeneralRe: comms config Pin
David Crow26-Jun-03 3:14
David Crow26-Jun-03 3:14 
GeneralRe: comms config Pin
andyg.10126-Jun-03 3:47
andyg.10126-Jun-03 3:47 
GeneralRe: comms config Pin
David Crow26-Jun-03 3:59
David Crow26-Jun-03 3:59 
GeneralRe: comms config Pin
andyg.10126-Jun-03 4:16
andyg.10126-Jun-03 4:16 
GeneralRe: comms config Pin
David Crow26-Jun-03 4:21
David Crow26-Jun-03 4:21 
GeneralRe: comms config Pin
andyg.10126-Jun-03 4:30
andyg.10126-Jun-03 4:30 
GeneralRe: comms config Pin
David Crow26-Jun-03 4:40
David Crow26-Jun-03 4:40 
GeneralRe: comms config Pin
andyg.10126-Jun-03 4:53
andyg.10126-Jun-03 4:53 
GeneralRe: comms config Pin
David Crow26-Jun-03 4:59
David Crow26-Jun-03 4:59 
GeneralRe: comms config Pin
andyg.10126-Jun-03 6:54
andyg.10126-Jun-03 6:54 
GeneralGet File System Name (FAT, NTFS etc...) Pin
rohit.dhamija26-Jun-03 2:26
rohit.dhamija26-Jun-03 2:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.