Running in Emulator. But not in Device.

Posted on 2002-04-19
Last Modified: 2013-12-27
I tired a program using createDIBSection and tried to fill that buffer.This buffer contains pixel information of a bitmap..My code works smoothily in my evc emulator..But when i tried it in my pocketPC the allocating of buffer is not working..Y this happend?

Main parts of my code is

//Bitmap information
bitmapinfo.bmiHeader.biWidth=screenWidth  ;

COLORREF pBuffer ;
 pBuffer = (COLORREF*)calloc((screenWidth * screenHeight*3 + 1000) ,sizeof(int));
     hTargetBitmap =     CreateDIBSection(hDC,&bitmapinfo,DIB_RGB_COLORS,(void**)&pBuffer,NULL,0);
     HBITMAP old=(HBITMAP)SelectObject(pDC,hTargetBitmap);

//Fillimg Buffer
COLORREF convertTo24 = convertColor24(pixcolor);
int j=0;
for( int l = 1; l <= count; l++)
 pBuffer[j++] = convertTo24;

My problem is when I run my program in my device(Compaq ipac ) the value of convertTo24 is not assigned to pBuffer for not even a single time...:(..Funny thing is its works fine in my default emulator..
Pls help me..

Question by:sujeeshlal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 23

Expert Comment

ID: 6954893
Remove the following three lines.

HBITMAP old=(HBITMAP)SelectObject(pDC,hTargetBitmap);

First, it is wrong because you select a bitmap into a DC and then delete the DC without selecting the old bitmap back. Second, you don't need to select the bitmap into a DC before filling the buffer.

Author Comment

ID: 6959464
Hi, thanx for ur help..But Now only I noticed a strange error in createDIBsection as showing 'invalid parameter' when I run it in Device..Its OK when I run it in Default emulator..Pls help me..
LVL 23

Expert Comment

ID: 6960776
1. You need to set the biSize member before calling CreateDIBSection().

bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

2. The data type of pBuffer should be a pointer.

COLORREF *pBuffer;
Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.


Author Comment

ID: 6964971
I did both ..But in vain.:((
LVL 23

Expert Comment

ID: 6966796
So, which function is failing now? What is the error code?

Author Comment

ID: 6967558
createDIBSection is failed as "invalid parameter" error code 87..But if i run that program in my WINCE default emulator its works fine..plss help..
LVL 23

Accepted Solution

chensu earned 50 total points
ID: 6967608
From Windows CE documentation,

"For 16bpp or 32bpp non-palettized images, the color table must be three entries long; the entries must specify the values of the red, green, and blue bitmasks. Also, the biCompression field in the BITMAPINFOHEADER structure should be set to BI_BITFIELDS. BI_RBG is not supported for these bit depths."

I never use an emulator to develop CE applications. Always use a real CE device.

Author Comment

ID: 6967912
Haaai, Thaaanx a lot.Atlast I got my screen.I changed the biCompression to BI_BITFIELDS and its works..still there is some color problems in my bitmap..Anyway thaaaanx a lot for ur great information..Im really thrilled with that answer.
LVL 23

Expert Comment

ID: 6969568
I believe that the color problems are due to the incorrect mask.

"If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, the bmiColors member contains three DWORD color masks that specify the red, green, and blue components, respectively, of each pixel. Each DWORD in the bitmap array represents a single pixel."

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently asked a question ( about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, ( because one time I did this and I essentially had a bricked …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question