Solved

Best way to rotate a CBitmap image

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 55
substring method in java 1 142
Use of condition with 'serial' in ansible 2 102
Problem to open Excel file 15 264
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

734 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