I tried to show the memory image passed from unsigned char * in VC++ MFC Windows but I couldn't manage to see until now. Actually, it is working in the other SDK and functions for verification's purpose except display.
My code are as below and I hope some one will advise me to close the case as soon as possible. - bool Dlg::Start()
-
{
-
LPCWSTR fileName = _T("C:\\test.bmp");
-
greyMemImage = LoadBMPFromFile(fileName);
-
-
// Display Image or Pattern here for Passing Data is correct
-
VECTOR_BYTE vecByte;
-
FILE* fpr = _wfopen(lpszFileName, L"rb");
-
-
if (fpr == NULL)
-
{
-
return false;
-
}
-
-
long lFileLength = _filelength(_fileno(fpr));
-
vecByte.resize(lFileLength, 0);
-
-
fread((void*)&(vecByte[0]), sizeof(unsigned char), lFileLength, fpr);
-
fclose(fpr);
-
fpr = NULL;
-
-
CDC* pDC = GetDC();
-
LPBYTE lpDIBBits = NULL;
-
LPBYTE pBWImageData = &(greyMemImage [0]);
-
int iColors = 0;
-
PBITMAPINFO pbitmapinfo = NULL;
-
PBITMAPINFOHEADER pbitmapinfoheader = NULL;
-
DWORD cbdwColorTable = 0;
-
int iMapMode = 0;
-
if (m_hbmImage != NULL)
-
{
-
DeleteObject (m_hbmImage);
-
m_hbmImage = NULL;
-
}
-
-
if (m_hdcImage != NULL)
-
{
-
DeleteDC (m_hdcImage);
-
m_hdcImage = NULL;
-
}
-
-
pbitmapinfo = (PBITMAPINFO)(pBWImageData + sizeof(BITMAPFILEHEADER));
-
pbitmapinfoheader = (PBITMAPINFOHEADER)(pBWImageData + sizeof(BITMAPFILEHEADER));
-
-
iColors = 1 << (pbitmapinfoheader -> biBitCount);
-
if (pbitmapinfoheader -> biBitCount >= 24)
-
cbdwColorTable = 0;
-
else
-
cbdwColorTable = (1 << (pbitmapinfoheader -> biBitCount)) * sizeof(RGBQUAD);
-
-
lpDIBBits = (LPBYTE)(pBWImageData + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + cbdwColorTable);
-
m_lImageWidth = (int)(pbitmapinfoheader -> biWidth);
-
m_lImageHeight = (int)(pbitmapinfoheader -> biHeight);
-
-
if (m_hdcImage == NULL)
-
m_hdcImage = CreateCompatibleDC(pDC -> m_hDC);
-
-
iMapMode = GetMapMode (pDC -> m_hDC); // Obtain mapping mode
-
SetMapMode (m_hdcImage, iMapMode); // Set memory DC mapping mode
-
-
if (m_hbmImage == NULL)
-
{
-
m_hbmImage = MyCreateBitmap(pDC -> m_hDC, pBWImageData, m_lImageWidth, m_lImageHeight, iColors);
-
-
}
-
-
SelectObject(m_hdcImage, m_hbmImage);
-
-
SetStretchBltMode((HDC)m_hdcImage, (int)HALFTONE);
-
StretchDIBits
-
(
-
(HDC)m_hdcImage, // handle of device context
-
(int)0, // x-coordinate of upper-left corner of dest. rect.
-
(int)0, // y-coordinate of upper-left corner of dest. rect.
-
(int)m_lImageWidth, // width of destination rectangle
-
(int)m_lImageHeight, // height of destination rectangle
-
(int)0, // x-coordinate of upper-left corner of source rect.
-
(int)0, // y-coordinate of upper-left corner of source rect.
-
(int)m_lImageWidth, // width of source rectangle
-
(int)m_lImageHeight, // height of source rectangle
-
(CONST VOID*)lpDIBBits, // address of bitmap bits
-
(CONST BITMAPINFO *)pbitmapinfo, // address of bitmap data
-
(UINT)DIB_RGB_COLORS, // usage
-
(DWORD)SRCCOPY // raster operation code
-
);
-
-
ReleaseDC(pDC);
-
-
InvalidateRect (NULL, TRUE);
-
return true;
-
}
-
Thanks in advance
0 1455 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jethro |
last post by:
This may be an easy question for you experienced guys, but not for me.
I have written lots of code in C, but not C++ and not in windows (old
fart).
I'm working on a simple program to learn the...
|
by: Niranjan podduturi |
last post by:
Hello Friends
Iam niranjan Developing MDI Application in vc++6.0
when iam displaying text in windows iam using OnDraw and OnChar
functions.
in OnChar function iam incrementing the x,y...
|
by: Marek Kurowski |
last post by:
Yo!
I design web browser in VC++. I need a web browser, in which I can display
html in a litle changed form.
The best control is CHtmlView with IWebBorwser2 (do you know other way?).
But in...
|
by: nandha |
last post by:
H
I have a doubt in VC++ regarding file reading and displaying in the GUI (Dialog
I have a binary file, which contains several piece of information , i have to read the information continuously...
|
by: |
last post by:
Everything seems to be moving to .NET and VC++ seems to be adding a lot of
managed code support every new release.
The questions: is unmanaged code in VC++ beeing phased out in favour of
managed...
|
by: Sarah Smith |
last post by:
Hello,
I am a bit of a newbie to VB.NET, but not totally new. I took the
plunge recently and decided (along with my colleagues), to try to
convert/port a VB6 client/server app to .Net.
(I'm...
|
by: S Wheeler |
last post by:
Hi all -
I am trying to create an instance of a vb .net class containing a form from
unmanaged vc++. The vb.net is a dll. How to do this ? I am trying #import by
can't seem to get it quite...
|
by: ramu |
last post by:
Hi,
I want to call a vc++ function from a c program on linux. So
when I do this dosen't the VC++ datatypes differ with c datatypes.
Because we don't have some vc++ data types in c. I have to...
|
by: meyzhong |
last post by:
Hi,
I am new to Visual C++ (6.0). I want to put all the print information
in different lines into a box.
I create a EDIT dialogue box, and then add a CString variable (m_MSG)
to the dialogue...
|
by: Norman Diamond |
last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet
Framework 2. Options are set in the setup project properties, so if these
two dependencies are not already installed then...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |