15,897,891 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Lam Giang (Top 3 by date)
Lam Giang
5-Jun-12 23:52pm
View
Yes, it really helps.
Lam Giang
5-Jun-12 9:44am
View
This is the code snippet I tested
<pre lang="c++">
CImage img;
CImage sm_img;
img.Load(jpgFileName);
CDC *screenDC = GetDC();
CDC *pMDC = new CDC;
pMDC->CreateCompatibleDC(screenDC);
CBitmap *pb = new CBitmap;
int iNewWidth = 80;
int iNewHeight = 60;
pb->CreateCompatibleBitmap(pMDC, iNewWidth, iNewHeight);
//SetStretchBltMode(pMDC->m_hDC,COLORONCOLOR);
img.StretchBlt(pMDC->m_hDC,0, 0, iNewWidth, iNewHeight, SRCCOPY);
// The next two lines test the image on a picture control.
// The output has wrong color palette, like my initial version
HDC hdcpic = ::GetDC(m_ClipPreview.m_hWnd);
img.StretchBlt( hdcpic,0, 0, iNewWidth, iNewHeight, SRCCOPY);
CBitmap *pob = pMDC->SelectObject(pb);
// The next lines create a black image
sm_img.Attach((HBITMAP)(*pb));
sm_img.Save(sjpgFileName);
img.Detach();
ReleaseDC(screenDC);
</pre>
I am running VS2005 on Windows 7, screen resolution 1280x800, 32 color bit
Lam Giang
5-Jun-12 8:46am
View
In the first version, I got a bad image, but in the version using your solution
I've got a black one. Still do not understand