Home > Archive > VC Language > May 2006 > CBitmap problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
|
Could anyone out there help me fix this dorky program?
#include <iostream>
#include <fstream>
#include <afxwin.h>
#include <windows.h>
using namespace std;
void getres(int &height, int &width);
BOOL MyLoadBitmap (std::string szFilename);
int main (int argc, char *argv[])
{
int height, width;
//CImage image;
bool bbitmap;
std::string inputfilename = "test.bmp";
//ifstream inputfile (inputfilename.c_str());
bbitmap = MyLoadBitmap (inputfilename.c_str());
getres(height, width);
return 0;
}
void getres (int &height, int &width)
{
width = 640;
height = 480;
}
BOOL MyLoadBitmap(std::string szFilename)
{
// ASSERT(szFilename);
DeleteObject();
HBITMAP hBitmap = NULL;
hBitmap = (HBITMAP)LoadImage(NULL, (LPCSTR) szFilename.c_str(),
IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
return Attach(hBitmap);
}
======================================
c:\Documents and Settings\Jacky.ETC-JACKY\LPR2.0\LPR2.0\lpr2_0.cpp(45):
error C2065: 'Attach' : undeclared identifier
c:\Documents and Settings\Jacky.ETC-JACKY\LPR2.0\LPR2.0\lpr2_0.cpp(40):
error C2660: 'DeleteObject' : function does not take 0 parameters
c:\Documents and Settings\Jacky.ETC-JACKY\LPR2.0\LPR2.0\lpr2_0.cpp(20):
warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance
warning)
Thanks in advance
Jack
| |
| Igor Tandetnik 2006-05-23, 10:05 pm |
| "Jack" <jl@knight.com> wrote in message
news:%238u$E6tfGHA.1456@TK2MSFTNGP04.phx.gbl
> Could anyone out there help me fix this dorky program?
>
> BOOL MyLoadBitmap(std::string szFilename)
> {
> // ASSERT(szFilename);
> DeleteObject();
>
> HBITMAP hBitmap = NULL;
> hBitmap = (HBITMAP)LoadImage(NULL, (LPCSTR) szFilename.c_str(),
> IMAGE_BITMAP, 0, 0,
> LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
> return Attach(hBitmap);
> }
>
> ======================================
> c:\Documents and
> Settings\Jacky.ETC-JACKY\LPR2.0\LPR2.0\lpr2_0.cpp(45): error C2065:
> 'Attach' : undeclared identifier
You are calling a function named Attach, but you don't declare or define
it anywhere in your program.
> c:\Documents and
> Settings\Jacky.ETC-JACKY\LPR2.0\LPR2.0\lpr2_0.cpp(40): error C2660:
> 'DeleteObject' : function does not take 0 parameters
http://msdn.microsoft.com/library/e...evcons_1vsk.asp
DeleteObject takes one parameter. You are not passing any parameters to
it.
c:\Documents and
> Settings\Jacky.ETC-JACKY\LPR2.0\LPR2.0\lpr2_0.cpp(20): warning C4800:
> 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
This warning is harmless and can be safely ignored. Though for
consistency, you might want to settle on using either BOOL or bool
throughout and avoid mixing the two.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
| |
|
|
"Igor Tandetnik" <itandetnik@mvps.org> 撰寫於郵件新聞:%23Wx1aMufGHA.2172@TK2MSFTNGP04.phx.gbl...
> "Jack" <jl@knight.com> wrote in message
> news:%238u$E6tfGHA.1456@TK2MSFTNGP04.phx.gbl
>
> You are calling a function named Attach, but you don't declare or define
> it anywhere in your program.
I want to use
class CMyBitmap : public CBitmap
{
.....
};
But don't know where to start.
Thanks
Jack
>
>
> http://msdn.microsoft.com/library/e...evcons_1vsk.asp
>
> DeleteObject takes one parameter. You are not passing any parameters to
> it.
>
> c:\Documents and
>
> This warning is harmless and can be safely ignored. Though for
> consistency, you might want to settle on using either BOOL or bool
> throughout and avoid mixing the two.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
| |
|
| BTW, can we just use CBitmap without MFC?
Thanks
Jack
"Jack" <jl@knight.com>
> "Igor Tandetnik" <itandetnik@mvps.org> ???gco?l¥o·s?D:%23Wx1aMufGHA.2172@TK2MSFTNGP04.phx.gbl...
>
>
> I want to use
> class CMyBitmap : public CBitmap
> {
> .....
> };
> But don't know where to start.
> Thanks
> Jack
>
>
>
| |
| Igor Tandetnik 2006-05-23, 10:05 pm |
| "Jack" <jl@knight.com> wrote in message
news:u0Oa2QufGHA.4080@TK2MSFTNGP03.phx.gbl
> I want to use
> class CMyBitmap : public CBitmap
Why? CBitmap wasn't really designed to be derived from.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
| |
|
|
"Igor Tandetnik" <itandetnik@mvps.org> 撰寫於郵件新聞:eQrP5TufGHA.1204@TK2MSFTNGP02.phx.gbl...
> "Jack" <jl@knight.com> wrote in message
> news:u0Oa2QufGHA.4080@TK2MSFTNGP03.phx.gbl
>
> Why? CBitmap wasn't really designed to be derived from.
Because CBitmap is where "attach" comes from.
Also a whole lot of handy methods...
Thanks
Jack
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
| |
|
| Hi Igor and other guys,
I have fixed all the compilation errors, leaving behind some link time
errors. The problem I am having is I can't use CBitmap without MFC.
So if some of you know, please help
Thanks
Jack
"Jack" <jl@knight.com> 撰寫於郵件新聞:uYYbuZufGHA.1320@TK2MSFTNGP04.phx.gbl...
>
> "Igor Tandetnik" <itandetnik@mvps.org> ???gco?l¥o·s?D:eQrP5TufGHA.1204@TK2MSFTNGP02.phx.gbl...
>
>
> Because CBitmap is where "attach" comes from.
> Also a whole lot of handy methods...
> Thanks
> Jack
>
>
>
| |
| Tim Roberts 2006-05-26, 4:13 am |
| "Jack" <jl@knight.com> wrote:
>
>Hi Igor and other guys,
>I have fixed all the compilation errors, leaving behind some link time
>errors. The problem I am having is I can't use CBitmap without MFC.
>So if some of you know, please help
If you want to use an MFC class, then you want MFC. You don't have to
convert your entire application.
However, ATL includes a CImage class that probably does what you want. ATL
is much lighter weight than MFC. #include <atlimage.h> and look up CImage
in MSDN.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
|
|
|
|
|