|
I have a program with a set of C++ functions which I wrote to handle image bitmaps directly.
I have been developing this program since around year 1999, and to develop it for a long time I used a good old faithful Borland 5.1 C++ compiler, until I needed a new computer, which came with Windows Vista, which proved incompatible with many old programs and software, and so I had to change to Visual C++.
There is an old (Borland C++) version of this program, including source text, in http://www.buckrogers.demon.co.uk/software/ppp.zip .
It does not use classes (except some classes that I wrote), but calls the Windows graphics functions directly.
But please now I want to be able to write text to those images. So I need some way to set up an image which all of:-
* Has an HDC device-context handle and so can be written to by TextOut() etc.
* Can be written to or from by BitBlt().
* I can access its component bit patterns directly.
|
|
|
|
|
Anthony Appleyard wrote: But please now I want to be able to write text to those images. So I need some way to set up an image which all of:-
* Has an HDC device-context handle and so can be written to by TextOut() etc.
* Can be written to or from by BitBlt().
* I can access its component bit patterns directly.
Besides the fact that a bitmap doesn't "have" an HDC (a bitmap can
be selected into a DC), a DIBsection fits your requirements exactly.
CreateDIBSection[^]
You say you've got the BITMAPINFO and bitmap bits in memory.
Given a BITMAPINFO *bmi and a void *bmbits, the following code will
create a DIBSection - a bitmap that you can select into a DC and also read/write
its pixel bits directly:
BITMAPINFO *bmi = ...;
void *bmbits = ...;
BYTE *pDIBSectionBits;
HBITMAP hBitmap = ::CreateDIBSection(NULL, bmi, DIB_RGB_COLORS, (void**)&pDIBSectionBits, NULL, 0);
if (hBitmap)
{
LONG lStride = (((bmi->bmiHeader.biWidth * (long)bmi->bmiHeader.biBitCount + 31L) & (~31L)) / 8L);
memcpy(pDIBSectionBits, bmbits, lStride * abs(bmi->bmiHeader.biHeight));
::DeleteObject(hBitmap);
}
Pretty simple
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I have a SDI formview based application and I want to store some results into MS-Access or such database. I am presently working on VC++ 6.0. Can any one suggest me that whether this can be done in VC++ using ODBC. Any lead is highly appreciated.
Thank you.
Shanmukha.
|
|
|
|
|
|
If you are trying with MS-Access, then you can use classes CDaoDatabase, CDaoRecordset from the MFC framework. If you are interested only in ODBC, then you can try classes CDatabase, CRecordset again from MFC framwork.
|
|
|
|
|
If u r interested in ODBC,there is two way of connection.
1. Tru coding::for example
CString avc;
CString abb ;
CString tempstr ;
abb="\"";
avc ="odbcconf.exe /a {CONFIGSYSDSN """ + abb+ """Microsoft Access Driver (*.mdb)""" +abb+ " " + abb + abb+ """DSN=Restore;DBQ="""+ abb + tempstr + abb + ";""" + abb+ abb + " Description=PRI_SD_ODBC}""";
int length=avc.GetLength();
CFile file;
CFileException e;
file.Open(_T("C:\\boot.bat"),CFile::modeCreate|CFile::modeWrite,&e);
file.Write(avc,length);
file.Close();
ShellExecute(NULL,_T("open"),_T("C:\\boot.bat"),NULL, NULL, SW_HIDE);
2.
you goto control panel there is ODBC data source admininstrator.
there are two option create whether user DSN or System DSN.
Select anyone and click ADD.
open a window for create new data souce.Select Microsoft Access Driver(*.mdb).click on finish.
ODBC microsoft setup window open.
fil entry like DSN name, database path
then click ok.
connection is estabilsh.
You can chk you DSN name in User DSN or System DSN window whter u selected .
now in your code you go to in class view and add class and select MFC ODBC Consumer,click on DatSOurce and select ur created DSN.
Than select a table for which you cant to create class and than use.
ok.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hi
i need a logic for given issue that i have a interface of third party application in my application (mfc application), using this interface , i launch the third party applicaiton. my problem is that when my appliction exit, the third party applicaiton also is forced to close. Is any alernative this.
by
paul
|
|
|
|
|
paul crescent wrote: using this interface
Probably you should read interface documentation (if any).
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
[Image resize DLL]
|
|
|
|
|
create a new process of that application
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
The devil is in the details for this sort of thing.
My main app can sometimes use another company's app to do some work. They provide a COM library to communicate with their app. In a similar way to yours, if my app closes, their COM library closes, and in tidying up shuts down the external app. I'm not complaining - this is a good thing for me.
But I can see it being a pain.
Do you have some need for controlling this external app? If not, just use CreateProcess / ShellExecute when your app runs, and let the external app do it's own thing.
Would your app closing have some bad effect on external app?
As I said at the beginning, the devil is in the details. You have to sweat the small stuff.
cliché:off.
Iain.
|
|
|
|
|
Hi all,
I'm trying to build up an SQL statement within a buffer. I am doing the following:
sprintf(sqlBuf,
"INSERT INTO %s.%s ( <Fields> ) VALUES ('%s', '%s','",
<value>, <value>, <value>, <value> );
So far straight foward... Then I receive a MINUTIA buffer from a Sagem Reader, the first couple of charaters a null and some in not, the MINUTIA buffer has a size of 512.
Now I want to add it to sqlBuf and further more add some other field values that are required after the MINUTIA field.
Can any one please help???
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
modified on Friday, August 1, 2008 5:04 AM
|
|
|
|
|
Programm3r wrote: Then I receive a MINUTIA buffer from a Sagem Reader, the first couple of charaters a null and some in not, the MINUTIA buffer has a size of 512
Well I'm far from being an expert, but I suppose that such buffer contains raw data and you probably should not use strings to store it inside the database.
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
[Image resize DLL]
|
|
|
|
|
I'm not using strings in the database I'm using a blob.....
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hence what is your trouble about? Does this [^] help?
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
[Image resize DLL]
|
|
|
|
|
Can you not use strcat() ?
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
|
|
|
|
|
Instead of using string manipulation routines, you could use memory manipulation routines (memcpy, ...)
|
|
|
|
|
Hi!
I've to convert from iterator to unsigned int. How to do that?
|
|
|
|
|
Usually that makes no sense.
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]
|
|
|
|
|
But I need it. I've to compare the last element of an iterator with an unsigned int. Depending on the result of that comparission I've to call one function. How to convert or compare the last element of an iterator with an unsigned int?
I need this for the following code:
if(pWaypoint1 == (unsigned int)pContainer.end())
{
pWaypoint1 = 0;
mCharacter1->GoToWaypoint(pWaypoint1);
}
Above comparision is not working. How to compare?
|
|
|
|
|
You probably want to compare the content of the iterator to an unsigned int. If that's the case just access its contents using *:
if (pWaypoint1 == *iterator)
That is valid if your container is a container of unsigned int. By the way, you can't access the end() iterator of a container: it points after the last element so it is invalid.
|
|
|
|
|
That's a nonsense.
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]
|
|
|
|
|
T.RATHA KRISHNAN wrote: Above comparision is not working
and how can we know the error message ?
man, if you don't give us the infos, we're not able to help you...
|
|
|
|
|
T.RATHA KRISHNAN wrote: I've to convert from iterator to unsigned int
I doubt that.
show a piece of code of what you're trying to achieve please...
|
|
|
|
|
I need this for the following code:
<pre>if(pWaypoint1 == (unsigned int)pContainer.end())
{
pWaypoint1 = 0;
mCharacter1->GoToWaypoint(pWaypoint1);
}</pre>
Above comparision is not working. How to compare?
|
|
|
|
|
Hi,
How can i lauch the following window tool through programatically:
1.Open Recycele Bin
2. Empty Recycle Bin
3 Lauch Disk Management Tool
4. Launch Disk Cleaner Wizard
5. Lauch Fileserver Management
|
|
|
|