|
You cna pass the buffer into a CBitmap constructor, although I'm not sure if a printer DC will print any bit depth DDB. I'd play it safe and create a DIBSection, then you can just memset the buffer into it.
If you call CreateDIBSection, you get a pointer to the data and you can copy your buffer into it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
If I use StretchBlt, can I print "color" image ? (I mean, if my printer is color...)
Another API I found is: DrawDibDraw, can I also use this API to print "color" image ?
|
|
|
|
|
manio wrote:
f I use StretchBlt, can I print "color" image ? (I mean, if my printer is color...)
OF course, that is what COLORONCOLOR is for, to smooth the colours when stretching.
manio wrote:
Another API I found is: DrawDibDraw, can I also use this API to print "color" image ?
Must be - no point having a 2 color DIB. I believe this API is part of VFW, I know Chris' DIBSection wrapper uses it and I believe it does dithering. But I've never used it so I can't comment beyond that.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian,
One more question about StretchBlt..
suppose my bitmap data to be printed is in some buffer like this:
pCurrentImage, (i.e, as the following
class CRGBImage
{
public:
BYTE* data;
int m_nWidth; // in pixel
int m_nHeight;
};
Now I already get something like this: CRGBImage* pCurrentImage...
Then I want to print this image data, so I wrote the following codes.
CPrintDialog dlg( FALSE );
CDC dc;
dc.Attach( dlg.GetPrinterDC() );
//calculate printing area(width and height)
int pwidth = dc.GetDeviceCaps(HORZRES);//get width of printing area
int pheight = dc.GetDeviceCaps(VERTRES);//get height of printing area
Now, how can I copy my bitmap data to dc ?
And, for the following StretchBlt API:
BOOL CDC::StretchBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop );
(Take the width for example)
The above parameter nSrcWidth = pCurrentImage->m_nWidth, right ?
And, how about the nWidth ? How to calculate it if I want to print to the original dimension of my bitmap ?
How to calculate pSrcDC ? (Do I just use: dc.StretchBlt(...) as dc mentioned above ? Because there are 2 DCs, I got kind of confused !! )
And, when to put "COLORONCOLOR StretchBlt mode" as you mentioned last time ?
I know I probably asked too many questions. Your any reply would be greatly appreciated..
|
|
|
|
|
manio wrote:
Now, how can I copy my bitmap data to dc ?
Not AFAIK, in that the command that does this is StretchBlt. I would imagine writing an equally efficient streching routine that does COLORONCOLOR would be tedious, and kind of redundant when it's in front of you. Just create a DIBSection with the width and height, you have a DSC if you want, but if you don't specify PAL_COLORS the DC paramater can be NULL anyhow. Then bitblt your bits into it, and stretchblt to the screen. Yes, you need to make another copy to do that, but that's really the best way I can see.
manio wrote:
And, how about the nWidth ? How to calculate it if I want to print to the original dimension of my bitmap ?
Like I said before, your original bitmap has a dimension that relates to the resolution and size of your monitor - it's NOT a real number, it's a number of pixels. Or do you mean aspect ratio ? Use the ratio of bitmap width to height to calculate the size of the aspect you're not filling the page with. If that comes out too big for the page, use the other one.
For example, if my bitmap is 2 x 3 pixels and I am drawing with a width of 6, I get the height by going 6 * 3 /2 = 9.
manio wrote:
How to calculate pSrcDC ? (Do I just use: dc.StretchBlt(...) as dc mentioned above ? Because there are 2 DCs, I got kind of confused !! )
Once you've created the DIBSection you need to select the HBITMAP returned from CreateDIBSection into a DC. Create it like this:
CDC srcDC;
srcDC.CreateCompatibleDC(&dc);
Now the DC is compatible with the print DC. Select your image into it, and stretchblt. Don't forget to go dc.SetStretchBltMode(COLORONCOLOR);
manio wrote:
I know I probably asked too many questions. Your any reply would be greatly appreciated..
Printing is a pain, printing graphics doubly so. I hope this helped.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
in the View.h file there is a method,
public:
CXXXDoc* GetDocument();
but there is no CXXXDoc related information declared before we use it,
and sometimes if i add some members to the CXXXView.h, I should Add the
declaration
class CXXXDoc;
before i can sucessfuly compile it.
why?
thanks
|
|
|
|
|
That's called forward declaring. You're telling the compiler that CXXXDoc is a class. Since you're not actually referencing the class in the .h file, that's all the compiler needs to know at this point (It's a pointer to a class).
If you had a function which accessed the class such as:
CXXXView::dosomething(){GetDocument->DoSometing();};
Then you would need to include the header.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Hi!
I need some help with one of my programs. It won't start unless Visual C++ is installed on the computer. If Visual C++ isn't installed then nothing happens when I try to start the program. Does anybody know what might cause this? I've used the dependency checker in Visual C++ to see if there are any DLLs missing but the program doesn't find anything wrong...
|
|
|
|
|
Which version of the VC++ are you using (standard, professional)?
Are you using some ActiveX controls in your applications?
What type of application it is, MFC, ATL etc?
Please try to use the Dependency Walker (or Depends) utility to find out which components your application depends on.
Best regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan, and open for programming contract anywhere!
|
|
|
|
|
Hello C++_Beginner,
1. It sounds like the reason for the failure to launch is due to one or more DLLs missing.
There is a very good tool at the SysInternals web site called "FileMon". The following is the link to it :
http://www.sysinternals.com/ntw2k/source/filemon.shtml
This program is available in Win9x, WinNT, Win2K and XP versions. It basically monitors all file activities including file openning and closing.
If there are any missing files (including DLLs) while your app is launching, this program will report it.
2. The other possible reason for failure is missing registry entries. Another tool at SysInternals called "RegMon" which monitors registry activities.
The following is the web address :
http://www.sysinternals.com/ntw2k/source/regmon.shtml
This may help you to identify missing registry entries that are required by the system to identify further DLLs (e.g. COM servers).
Try out these two utilities and I'm very sure they will be of great help to you.
Best of luck.
Regards,
Bio.
|
|
|
|
|
Did you compile in Release mode? if not, your program is linked against debug libraries, and will never work without VC.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Why it wont start unless VC++ is installed is because you have probably have checked the "As shared DLL" alternative in AppWizard. Then you'll need those files in the same dir as the exe to run a MFC app on another computer:
MFC42D.DLL
MFCO42D.DLL
MSVCRTD.DLL
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Make sure that if you are using shared DLL that you link to the Release versions of the DLL's.
Redistributing the debug dll's is a bad idea and may also be a violation of Microsoft's licence agreement.
Michael
|
|
|
|
|
Thanks for all the answers!
It is an MFC app and I'm using the release build so the program doesn't use any of the development dlls. I'm using two ActiveX controls, mediaplayer2 and MS Image Forms 2.0. My devenviroment is VC++ Pro.
Using the filemonitor program I can see that my program depends on MFC42.dll, MFC42LOC.dll, MSVCIRT.dll, OLE32.dll, OLEAUT32.dll, CLBCATQ.dll and MSVCRT.dll. Everything is successful when I load my program. I can't see anything wrong when I run the Regmonitor, the dependency walker v2.1 can't find anything wrong either.
The program just shuts down after having something to do with ~CLBCATQ.dll. I'm trying to run my program in W2k without VC++ installed. I know it works with VC++ installed.
I can't understand anything...? Any suggestions are welcome!
|
|
|
|
|
According to MSDN, having the ~CLBCATQ.dll present means that COM+ hasn't been installed correctly on your machine.
Are you using COM + services?
Michael
|
|
|
|
|
That's strange... No, I'm not using any COM+ services.
- Tobias
|
|
|
|
|
Please help! I am trying to make a CList of CUIntArray. Add a CUIntArray to the list, read the CUIntArray from the list and TRACE it to the debug window! Here is the code however when I try to compile i get the error...
'CUIntArray' : 'operator =' function is unavailable.... Please Help!
CString debug;
CUIntArray array;
CList <cuintarray,cuintarray&> list; // create the list
array.SetSize(3);
for (int x=0;x<3;x++)
{
array[x]=0;
}
list.AddTail(array); //create array and add to the list
POSITION pos=list.GetHeadPosition(); // get start position of list
int arraylength;
while (pos!=NULL)
{
list.GetNext (pos);
arraylength=(list.GetAt(pos)).GetSize();
for (int x=0;x
|
|
|
|
|
Which use of = ? Which line is the error occuring on?
--Mike--
My really out-of-date homepage
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I think it has something to do with
CUIntArray=CUIntArray causing a problem
the only way i can think to remedy this is to use a CStringList, and convert between characters and integers
template<class type,="" class="" arg_type="">
POSITION CList<type, arg_type="">::AddTail(ARG_TYPE newElement)
{
ASSERT_VALID(this);
CNode* pNewNode = NewNode(m_pNodeTail, NULL);
pNewNode->data = newElement; ////// this is where the error is!
if (m_pNodeTail != NULL)
m_pNodeTail->pNext = pNewNode;
else
m_pNodeHead = pNewNode;
m_pNodeTail = pNewNode;
return (POSITION) pNewNode;
}
|
|
|
|
|
i've found that this code can be used which when implemented is identical to the CList of CUIntArray.....
CString debug,str;
CStringList list;
for (int x=0;x<3;x++)
for (x=0;x<3;x++)
str.Insert(x,static_cast <char>(0)); // create string containing integer after convertion to character
AfxMessageBox(str);
list.AddTail(str); // add string to CStringList
POSITION pos=list.GetHeadPosition(); // get start position of list
for (x=0;x<list.getat(pos).getlength();x++)
{
=""
="" debug.format(="" "%d="" ",static_cast="" <int="">(list.GetAt(pos).GetAt(x)) ); // Get character from list convert to integer
TRACE (debug); //// display on Debug window with trace
}
|
|
|
|
|
I am trying to set the background color of a mini server to that of the container. Can I access the container's ambient properties from MFC's COleServerItem class? How is this typically done?
Thanks
~ Paul ~
|
|
|
|
|
Hi,
I find there is a slight inconvenience with the std::getline function in C++. Here is an example:
-----------------------------------------------------------
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::getline;
#include <string>
using std::string;
int main()
{
string strTemp;
cout << "Enter a sentence: ";
getline(cin, strTemp);
cout << "\nYou entered: "
<< strTemp << endl;
return 0;
}
-----------------------------------------------------
If you run the code above, and hopefully I did not leave anything out, out will find that after you entered a sentence and press Enter, the "cursor" will go to the next line, but the program does not move onto "You have entered: " until you press Enter the second time. In other words, I have had problems with the getline function in term of having to press Enter twice to get it to move onto the next algorithm.
I have tried for example:
getline(cin, strTemp, '\n');
It has the same effect.
Is there a way to get around having to press Enter twice?
Thanks,
Kuphryn
|
|
|
|
|
Probably, you're running into a known bug in Dinkumware's implementation of the C++ standard library. This article addresses the problem (look for the "Fix to <istream> " section) and proposes a fix.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
zen from cprogramming.com posted something about a bug in VC++:
http://www.cprogramming.com/cboard/showthread.php?s=a4253030337e8f0dc4d9e68fb761087c&postid=48172#post48172
That fixed the problem.
Kuphryn
|
|
|
|
|
Hi.
I am working on a simple program that reads data into memory in binary. It then write the data from memory to a second file in memory.
Is it possible to read from ifstream straight to an STL container instead of having to go through dynamic memory allocation?
Thanks,
Kuphryn
|
|
|
|