Solved

Best way to rotate a CBitmap image

Posted on 1997-03-01
1
1,212 Views
Last Modified: 2013-11-20
I need to rotate a CBitmap that may have any number of colors in it depending on the current system color palette. It needs to be turned 90 degrees counter-clockwise.  What is the best way to do this? I'm using Visual C++ 4.1 in NT 4.0 and Win95.

Sample code would be very appreciated!
0
Comment
Question by:Guy012897
1 Comment
 
LVL 1

Accepted Solution

by:
xbwen earned 200 total points
ID: 1300218
Hi:
  I used to do something like that, what I did is create a memory
DC to save the transfered the bitmap, then use BitBlt copy to screenDC, the transfer is:

   CDC bmpDC,memDC;
   bmpDC.CreateCompatibleDC(&dc);  
   memDC.CreateCompatibleDC(&dc);
   CBitmap *oldmBmp,trs_Bmp,*oldtBmp;
   trs_Bmp.CreateCompatibleBitmap(&dc,cxDIB,cyDIB);
   oldmBmp=bmpDC.SelectObject(&org_Bmp);
   oldtBmp=memDC.SelectObject(&trs_Bmp);    

   for (int y=0;y<cyDIB;y++)
    for (int x=0;x<cxDIB;x++)
         memDC.StretchBlt(y,cyDIB-x,1,1,&bmpDC,x,y,1,1,SRCCOPY);
   
  dc.StretchBlt(dstRect.left,
                dstRect.top,
                dstRect.Width(),
                dstRect.Height(),
                &trsDC,
                 0,
                 0,
                 cxDIB,
                 cyDIB,
                 SRCCOPY);
   
     bmpDC.SelectObject(oldmBmp);
     memDC.SelectObject(oldtBmp);  
 
 It works well, the problem is too slow for transfer big bitmap especially on slow machine(such as 640*480 on 486). but it is really a way though I don't think it is not the best way.
 Hopy I can help you.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question