Solved

Best way to rotate a CBitmap image

Posted on 1997-03-01
1
1,207 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now