Solved

Best way to rotate a CBitmap image

Posted on 1997-03-01
1
1,222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 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