Solved

Running in Emulator. But not in Device.

Posted on 2002-04-19
9
457 Views
Last Modified: 2013-12-27
Hi,
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  ;
     bitmapinfo.bmiHeader.biHeight=-screenHeight;
     bitmapinfo.bmiHeader.biPlanes=1;
     bitmapinfo.bmiHeader.biBitCount=32;
     bitmapinfo.bmiHeader.biCompression=BI_RGB;
     bitmapinfo.bmiHeader.biSizeImage=0;
     bitmapinfo.bmiHeader.biClrUsed=0;
     bitmapinfo.bmiHeader.biClrImportant=256;


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

//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..
Sujeesh


0
Comment
Question by:sujeeshlal
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:chensu
Comment Utility
Remove the following three lines.

pDC=CreateCompatibleDC(hDC);
HBITMAP old=(HBITMAP)SelectObject(pDC,hTargetBitmap);
DeleteDC(hDC);

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.
0
 

Author Comment

by:sujeeshlal
Comment Utility
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..
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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;
0
 

Author Comment

by:sujeeshlal
Comment Utility
I did both ..But in vain.:((
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 23

Expert Comment

by:chensu
Comment Utility
So, which function is failing now? What is the error code?
0
 

Author Comment

by:sujeeshlal
Comment Utility
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..
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
Comment Utility
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.
0
 

Author Comment

by:sujeeshlal
Comment Utility
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.
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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."
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When I was a beginner in Windows Mobile programming, even for small test I used to create a single MFC dialog-based application with one button, and put my test code in the OnLButtonDown method. For Pocket PC it worked fine, on some Windows CE d…
With Windows Embedded Handheld, called Windows Mobile, Microsoft re-designed the user interface. The Start Icon moved down to the bottom, inside the menu bar area.   If you need to hide the Start Icon and/or the SIP (soft input panel, softwar…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now