|
-
Jul 19th, 2003, 08:55 PM
#1
Thread Starter
Frenzied Member
How to draw quality images in C++
In my C++ to C# test post I mention that the test is not fair yet because the C# app draws much better images than the C++ app.
Here is the code that does the drawing:
Code:
HBITMAP hOldMemBmp= (HBITMAP)::SelectObject(imageDC, hBmp);
a::hOldBmp= (HBITMAP)::SelectObject(a::hdcMem, hMemBmp);
::StretchBlt(a::hdcMem, 0, 0, wndRect.right-wndRect.left,
wndRect.bottom-wndRect.top, imageDC, 0, 0, BmpW, BmpH, SRCCOPY);
::BitBlt(a::hdcMem, drawLocation->left, drawLocation->top, drawLocation->right - drawLocation->left,
drawLocation->bottom - drawLocation->top, imageDC, 0, 0, SRCCOPY);
::BitBlt(hDC, invalLocation->left, invalLocation->top,
invalLocation->right-invalLocation->left,
invalLocation->bottom-invalLocation->top, a::hdcMem, invalLocation->left, invalLocation->top, SRCCOPY);
I read about using SetStretchMode(HALFTONE); but it doesn't work on win98.
How would I draw/stretch an image as nice as C# does another way?
Last edited by aewarnick; Jul 19th, 2003 at 09:28 PM.
-
Jul 21st, 2003, 04:00 AM
#2
What are you using in C#?
It's not the language that draws the image, it's the algorithm. Maybe the .Net framework implements an algorithm that is not available in pure API (or simply not in sucky 9x series). If so, you could search the net for an implementation or implement it yourself.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 21st, 2003, 09:55 AM
#3
Thread Starter
Frenzied Member
Oh. Well one person suggested using GDI+ instead of GDI. My concerns are
1. How big is the runtime?
2. How slow is DrawImage in C++ using GDI+?
-
Jul 22nd, 2003, 01:57 AM
#4
1) Take a look. I think the dll is "gdiplus.dll" in the windows system folder (windows\system or winnt\system32).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 22nd, 2003, 05:09 AM
#5
Thread Starter
Frenzied Member
1.62 megs.
819k cabbed.
940k zipped.
Now the question is will I get in trouble if I send it along with my programs?
-
Jul 22nd, 2003, 07:43 AM
#6
Hyperactive Member
Gdiplus.dll is included with Windows XP. For information about which operating systems are required to use a particular class or method, see the More Information section of the documentation for the class or method. GDI+ is available as a redistributable for Windows NT 4.0SP6, Windows 2000, Windows 98, and Windows Me. To download the latest redistributable, see http://www.microsoft.com/msdownload/...sdkredist.htm.
-
Jul 22nd, 2003, 08:27 AM
#7
Thread Starter
Frenzied Member
Thank you transcendental. That is good. I guess it does not work on win95. GDI+ is part of the .net framwork.
I read something about MFC70.dll being better than before. I have never used MFC at all and am wondering if it includes standard controls like listbox, rtb, tb, context menu.
MFC70.dll has support for jpg, gif...but I did not see tif, which is my favorite image format.
-
Jul 22nd, 2003, 09:03 AM
#8
Hyperactive Member
I have never used MFC at all and am wondering if it includes standard controls like listbox, rtb, tb, context menu.
MFC does include those you mentioned. MFC has a learning curve.
MFC70.dll has support for jpg, gif...but I did not see tif, which is my favorite image format.
MFC doesn't have native support for jpeg until MFC 7 came out, which I think is ridiculous.
Maybe this class can help you.
CxImage
-
Jul 22nd, 2003, 09:15 AM
#9
Thread Starter
Frenzied Member
Have you compiled that class? I downloaded the source a while ago but have Dev and it is hard to compile thing with it.
I was wondering how big the dll is.
-
Jul 22nd, 2003, 09:37 AM
#10
MFC never had any image format support and probably never will have. That was never an aim of MFC, so it's not ridiculous either.
All format support available in MFC7 comes through GDI+ wrapped by the CImage class.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 22nd, 2003, 09:40 AM
#11
Hyperactive Member
Originally posted by aewarnick
Have you compiled that class?
Nope. In fact I haven't read the article myself. I'll read it in these few days since it have been on my IE bookmarks for quite some time, and report to you.
-
Jul 22nd, 2003, 10:06 AM
#12
Thread Starter
Frenzied Member
If anyone else knows about the CXImage class please jump in.
CornedBee, so to use MFC70 Image support you also need the GDI+ dll?
-
Jul 22nd, 2003, 03:01 PM
#13
Yes. The CImage class needs the GDI+ dll.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 22nd, 2003, 03:35 PM
#14
Thread Starter
Frenzied Member
Thank you. If anyone knows about the CXImage source code please let us know what it is like.
-
Jul 28th, 2003, 06:23 AM
#15
Hyperactive Member
I had a quick look at it last night. The accompanied source is in VC6 project workspace format. If you want to use CxImage in Dev-C++(I haven't tried yet), you would need to compile the dlls and static libs in VC (the easiest way out).
The CxImage is surprising easy to use. I just used a Load() member function to load the jpeg file and a Draw2() member function to blit to my DC. All accomplished with 2 calls without the usual CreateCompatibleBitmap() and CreateCompatibleDC() hassles.
The quick program I wrote to see the results, runs without problems in both Win98 and WinXP.
-
Jul 28th, 2003, 04:02 PM
#16
Thread Starter
Frenzied Member
Thanks transendental, I don't have a working edition of VC6, could you mail the dll's to me? I'll pm my e-mail.
How big are the dll's?
-
Jul 28th, 2003, 08:27 PM
#17
Hyperactive Member
Unfortunately, there are a number of them and some are quite big, and my yahoo email only allows attachment up to 1MB. And I don't have a POP3 account with my ISP.
I think it would be best if you can find a friend who can compile them for you.
However, I can email you the static libs(zipped up to less than 1MB), and you still need to download the source from article because the static libs needs the headers and I won't be emailing you the headers.
Please note I haven't tried the dlls out, only the static libs.
-
Jul 29th, 2003, 07:50 AM
#18
Hyperactive Member
aewarnick, forget about it, I couldn't get it to link in Dev-C++ at all.
-
Jul 29th, 2003, 02:00 PM
#19
Thread Starter
Frenzied Member
What I mean is, compile the dll's with VC++ and send them my way.
-
Jul 30th, 2003, 07:42 AM
#20
Hyperactive Member
Err... I mean I couldn't compile my Dev C++ program with VC6's compiled libraries.
-
Jul 30th, 2003, 08:22 AM
#21
They use different .lib formats.
I recommend that you create a dll project in Dev and add the source files manually.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 1st, 2003, 04:19 PM
#22
Thread Starter
Frenzied Member
I'll give that a try but I have the feeling that error upon error will be shown. But there is no stopping that. Thanks for all the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|