|
Jose's reply is great for HBITMAPs.
Just using the word "image" is extremely vague. It's a lot easier for
us to help you if you're a bit more specific. What kind of image?
What format is the image? etc...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Actually i am writing code to diaply image read by an imagescanner device.
In this i need to support all formats of images. So, i need to display an image which is in byte array format. How to do that?
|
|
|
|
|
hari_honey wrote: i need to support all formats of images
All? That's pretty ambitious.
Many image formats are published. You'll need to study the format specifications
and read/write the byte streams accordingly.
For BMP, GIF, JPEG, Exif, PNG, and TIFF, GDI+[^] can help.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You don't need to: images are just a byte arrays.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
I am trying to automate the excel into simpe MFC application. I am using excel 2007. But code is not working. Can one see any problem with this code?
#include "stdafx.h"
#include "afxdisp.h"
#include "excel.h"
#include "AutoExcel.h"
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
_Application app;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr <<_T("Fatal Error: MFC initialization failed")<<endl;
nRetCode = 1;
}
if(!AfxOleInit())
{
AfxMessageBox("Could not initialize COM dll");
return FALSE;
}
else
{
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel.");
}
else
{
app.SetVisible(TRUE);
AfxMessageBox ("Excel is Running!");
}
}
return nRetCode;
}
|
|
|
|
|
SRKSHOME wrote: But code is not working.
Which means what exactly ?
|
|
|
|
|
Excel is not starting.Excel object is not realy creating.I am always getting the message like "Couldn't Start excel". It is failing in below code.
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel.");
}
|
|
|
|
|
_Application::CreateDispatch() returns a BOOL .
The _Application class derives from COleDispatchDriver .
You should provide a pointer to a COleException in the call to CreateDispatch() to get hold of the error.
Read how here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I do not see com initialization code in your program.
call CoInitialize/CoInitializeEx to initialize COM.
I hope it helps.
Check rogers reply..
Regards,
Sandip.
modified on Friday, October 17, 2008 7:50 AM
|
|
|
|
|
The call chain of AfxOleInit() eventually calls ::CoInitializeEx() and sets up an STA.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Ohh.. Thanks for the info..
Regards,
Sandip.
|
|
|
|
|
SRKSHOME wrote: if(!AfxOleInit())
You need to call OleInitialize(NULL) instead.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks a lot David. It did work.
|
|
|
|
|
hi,
I'm using Visual Studio 2005 Professional Edition.
I created a project on .NET Framework (Windows Embedded CE 6.0).
When i run my project in DEBUG mode on my emulator, i get an error read as :
"Application Error:
Application MyProject.exe encountered a serious error and
must shutdown."
Please advise how to resolve this.
For info:
I have no such problem when I run my application in RELEASE mode.
S.O.S
Ema
|
|
|
|
|
Debugging would be a great idea. Also, try an appropriate forum. This is the native programming forum (C++/MFC).
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Why you asked this question here?
|
|
|
|
|
|
You can ask on the .NET Framework[^] but whats your language you used for your program c++ or?
|
|
|
|
|
Using C++...Anyway i've posted this question in .NET Framework section...
Thanks!
Ema
|
|
|
|
|
Hi all,
What's the most appropriate place to define this.
TCHAR szTempFile[MAX_PATH];
I've define it on the header file, is that OK.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
No - it can cause problems. If the header file is included in more than one source file (i.e. a body file) then the linker will complain about szTempFile being multiply defined (actual error will depend on your actual compiler). Effectively each body file gets its own variable with global scope called szTempFile. When the linker comes along it sees multiple versions of the variable and causes the error
The rule is that a variable name can be declared more than once but only defined once. The above line is a definition. Definitions should always live in the body files. If you want to share the variable between multiple body files then you need to include a declaration of the variable in the header file. You do this by putting the keyword extern in front of the declaration as follows
extern TCHAR szTempFile[MAX_PATH];
Graham
Librarians rule, Ook!
|
|
|
|
|
Yes, I tried it. But compiler give me an error 'illegal storage class'
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Which compiler? I created a test project in VS2003 and it works fine
File foobar.h
#pragma once
extern TCHAR szTempFile[MAX_PATH];
File foo.cpp
#include "stdafx.h"
#include "Foobar.h"
void DoIt()
{
szTempFile[0] = _T('a');
}
File bar.cpp
#include "stdafx.h"
#include "Foobar.h"
TCHAR szTempFile[MAX_PATH];
Graham
Librarians rule, Ook!
|
|
|
|
|
if you're coding C++, the best place for such a declaration is still in the class definition, as a member...
|
|
|
|
|
The most appropriate place is the place that gives the variable
the scope you desire.
If its scope is the duration of a function, put it in a function.
If its scope is global, put it anywhere outside a function.
etc...
Header files are typically for declarations. Variable instances
should be placed in source (c/cpp) files. Yours is an instance, so
shouldn't be in a header file.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|