|
blah blah bla...a bunch of useless techno-babble. Everyone knows the advantage is being able to
say "I used an abstract class" and nobody knows what you're talking about.
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
You can use OleLoadPicture().
The following code two-steps it - loads the JPG into a HBITMAP then draws the HBITMAP
If you just wanted load & draw it w/o the intermediate BMP you could call pPic->Render() into the dialog's DC.
#include <Ole2.h>
#include <olectl.h>
#define HIMETRIC_INCH 2540
HBITMAP LoadJpgFile(LPCTSTR filename)
{
HBITMAP hBmp = NULL;
if(filename && *filename)
{
HANDLE hFile = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if(hFile)
{
DWORD dwFileSize = GetFileSize(hFile, NULL);
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
if(hGlobal)
{
LPVOID pvData = GlobalLock(hGlobal);
if(pvData)
{
DWORD dwBytesRead = 0;
BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
GlobalUnlock(hGlobal);
if(bRead && (dwBytesRead==dwFileSize))
{
LPSTREAM pstm = NULL;
HRESULT hr = ::CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
if(pstm)
{
LPPICTURE pPic = NULL;
hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID_IPicture, (LPVOID*)&pPic);
if(pPic)
{
long lWidth=0, lHeight=0;
pPic->get_Width(&lWidth);
pPic->get_Height(&lHeight);
HDC hMemDC = CreateCompatibleDC(NULL);
if(hMemDC)
{
int nWidth = MulDiv(lWidth, GetDeviceCaps(hMemDC, LOGPIXELSX), HIMETRIC_INCH);
int nHeight = MulDiv(lHeight, GetDeviceCaps(hMemDC, LOGPIXELSY), HIMETRIC_INCH);
if((nWidth>=0) && (nHeight>=0))
{
HDC dcScreen = GetDC(NULL);
if(dcScreen)
{
HBITMAP hJpgBmp = ::CreateCompatibleBitmap(dcScreen, nWidth, nHeight);
if(hJpgBmp)
{
HBITMAP hPrevBmp = (HBITMAP)::SelectObject(hMemDC, hJpgBmp);
RECT rect = {0,0, nWidth,nHeight};
hr = pPic->Render(hMemDC, 0, 0, nWidth, nHeight, 0, lHeight, lWidth, -lHeight, &rect);
::SelectObject(hMemDC, hPrevBmp);
if(SUCCEEDED(hr))
hBmp = hJpgBmp;
else
DeleteObject(hJpgBmp);
}
DeleteDC(dcScreen);
}
}
DeleteDC(hMemDC);
}
pPic->Release();
}
pstm->Release();
}
}
}
GlobalFree(hGlobal);
}
CloseHandle(hFile);
}
}
return hBmp;
}
void DrawBitmap(HDC hDC, HBITMAP hBitmap, int nXDest, int nYDest)
{
BITMAP bm;
if (GetObject(hBitmap, sizeof(bm), &bm))
{
HDC hMemDC = CreateCompatibleDC(hDC);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
BitBlt(hDC, nXDest, nYDest, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);
}
}
void somefcn()
{
HBITMAP hBmp = LoadJpgFile(szJpgFile);
DrawBitmap(hDC, hBmp, x, y);
DeleteObject(hBmp);
}
<pre>
|
|
|
|
|
Hello,
If Unix is on the server and client has a Windows O.S then how do I get data from the server.
Which topics should I cover
Priya
|
|
|
|
|
prithaa wrote: how do I get data from the server.
Sockets or FTP are a few options.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
J2EE
|
|
|
|
|
Hello,
Thanks for your reply,
But will I be able to access database on a Unix server from my program written in MFC for Windows on the client side.
Do I need to know Unix before accessing data from a Unix server
Prithaa
|
|
|
|
|
don't mind for J2EE, i was joking.
but how are your data stored on the server ? do you have a database server ? or simple files ?
what is the medium ?
|
|
|
|
|
Hello,
It was a good joke. but I was terrified looking at those 4 letters 'J2EE'
I have a oracle database for unix.
Prithaa
|
|
|
|
|
prithaa wrote: I have a oracle database for unix.
Do you have an ODBC driver?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
prithaa wrote: But will I be able to access database on a Unix server from my program written in MFC for Windows on the client side.
Yes, of course.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
I don't know whether I have ODBC driver,which route should I follow in both the cases
Prithaa
|
|
|
|
|
If you do, then simply create a DSN that "points to" the Unix machine. I did this once when the target machine was Windows running Microsoft SQL. Unfortunately, it's been 6+ years ago so I've forgotten the details.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
Thanks for all your replies
Prithaa
|
|
|
|
|
Hi all.
I need menu in my dialog API, Sow I creat resource (Menu), whot I must do next?
|
|
|
|
|
open your dialog in the resource editor and see its properties. it has a property called Menu... choose your menu ID in the list.
that's it, the menu is now showing in your dialog.
now, if you want to add handlers on the menu items, do as if it was a button on your dialog; double click on it, or right click and choose add event handler...
|
|
|
|
|
|
Hi, I'm working with MFC's App in VS2005 and using Crystal Report (the version integrated in VS2005).
I need to modify the Report's Header to customize it for every use. Load it from a model(of file) and substitute it to the report header.
How can I do it? Can I do it with CR for VS2005?
Thanks a lot.
-- modified at 12:18 Thursday 22nd March, 2007
|
|
|
|
|
Hi
I want to be able to retrieve images and compress them in realtime, the amount of images I'm getting is about 100 or so per second, I have the compression filter in Directshow working, I am using the Cinepak Radius Codec, but it is way too slow. Is there a codec compression that may not compress as much but can operate at 100 frames per second.
Thanks
|
|
|
|
|
RTC is probably the quickest you will find. It just takes bunches of numbers, such as 00 00 00 00 and turns them into 04 00. Not so great if you have lots of unique pixels, but otherwise, it will give you a little bit of compression.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Thanks for the response,
I cant seem to find RTC Codec in Directshow, what is the name of the codec in Directshow, I installed a RtcApiSDK.msi from Windows, but it still didnt show up in Directshow.
What am I doing wrong?
|
|
|
|
|
It's a compression scheme that is common, I have no idea if DX has a filter for it.
And, as was said, I presume you have a good reason for capture 3x as many frames as the human eye can hope to see ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
RtcApiSDK is not a directshow filter.
Depending on image size, most/all of the DirectShow filters are going to be too slow (on modern
PCs) for 100fps.
Why do you need such a high frame rate? Motion pictures are 24fps....anything above 30fps for
viewing by a human is a waste of resources IMO.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
About 4 years ago, I did tests of the time by various codecs to compress a series of images to make an AVI file - the fastest was the Microsoft MPEG-4 codec (in the DLL MPG4C32.DLL). But I never managed to get a legal version of the Microsoft DLL (someone sent me a link and . . .)
Maybe its worth trying XVID and DIVX. When I was doing my development, I didn't find versions of those codecs which I could use to make AVI files, so I just used the "not 100% legal" microsoft DLL. Fortubately I've changed companies, the customer is happy, etc.
|
|
|
|
|
Hi All,
I have small application that i add in it some CTreeCtrl control.
In this i need in some cases to disable one of the sub item of some root element and i don't know how to do it.
Some one can help me ?
Thanks.
p.s : i need to disable only the sub item without the root item.
|
|
|
|
|
|