Click here to Skip to main content
15,911,132 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Converting int to CString Pin
Alvaro Mendez14-Dec-01 5:16
Alvaro Mendez14-Dec-01 5:16 
GeneralRe: Converting int to CString Pin
Cam14-Dec-01 5:48
Cam14-Dec-01 5:48 
QuestionHow to Change the 'Caption' of a CPropertyPage Pin
14-Dec-01 3:39
suss14-Dec-01 3:39 
AnswerRe: How to Change the 'Caption' of a CPropertyPage Pin
Joaquín M López Muñoz14-Dec-01 4:23
Joaquín M López Muñoz14-Dec-01 4:23 
GeneralCreating Excel files Pin
14-Dec-01 2:21
suss14-Dec-01 2:21 
QuestionHow do I create a "Virtual" Device Context? Pin
Jon Hulatt14-Dec-01 2:04
Jon Hulatt14-Dec-01 2:04 
AnswerRe: How do I create a "Virtual" Device Context? Pin
Joaquín M López Muñoz14-Dec-01 2:11
Joaquín M López Muñoz14-Dec-01 2:11 
GeneralRe: How do I create a "Virtual" Device Context? Pin
Jon Hulatt14-Dec-01 3:18
Jon Hulatt14-Dec-01 3:18 
Thanks for that info. It kind of works, but my stretchblt doesn't!
see:

CDC srcDC,destDC;

srcDC.CreateCompatibleDC(NULL);
destDC.CreateCompatibleDC(&srcDC);
destDC.SetStretchBltMode(COLORONCOLOR);
srcDC.SelectObject(m_Bitmap);
destDC.StretchBlt(0,0,WALLPAPER_SIZE_X,WALLPAPER_SIZE_Y,&srcDC,0,0,bm.bmWidth,bm.bmHeight, SRCCOPY);

int x,y;
for (y=0; y<WALLPAPER_SIZE_Y;y++)
{
    for (x=0;x<WALLPAPER_SIZE_X;x++)
    {
        m_PreviewPane.p_ImgData[ (WALLPAPER_SIZE_X * y) + x ]=destDC.GetPixel(x,y);
    }
}


OK. Let me explain what's happening here. I create a source device contect as you suggested, and a destination dc compatible with it. I select my source bitmap into the source device context (srcDC). I then try to strechblt, to scale the image to be WALLPAPER_SIZE_X by WALLPAPER_SIZE_Y in size. bm is a BITMAP structure, containing the source bitmap information.

Tracing through this in the debugger, everything seems valid. bm.bmWidth * bmHeight contain correct source size info, etc etc. But the stretchblt function returns 0 (which is a failure). GetLastError returns 0 as well, if i try that.

The nested loops at the bottom read the scaled bitmap into a previously allocated array. destDC.GetPixel always returns (COLORREF) 0xFFFFFFFF. if i change that line to use srcDC.GetPixel, It returns the proper data from my bitmap.

Basically, I have no idea why stretchblt is failing, and no ideas of how to trace through the problem.

Any help greatly appreciated.

Thanks

Jon

Sorry to dissapoint you all with my lack of a witty or poignant signature.
GeneralRe: How do I create a "Virtual" Device Context? Pin
Jon Hulatt14-Dec-01 3:31
Jon Hulatt14-Dec-01 3:31 
GeneralAccessing .MDB files Pin
Cris14-Dec-01 2:02
Cris14-Dec-01 2:02 
GeneralOpening a new IE window Pin
Rob Caldecott14-Dec-01 0:25
Rob Caldecott14-Dec-01 0:25 
GeneralRe: Opening a new IE window Pin
Philip Patrick14-Dec-01 14:21
professionalPhilip Patrick14-Dec-01 14:21 
GeneralActiveX For Connecting Database Pin
San13-Dec-01 23:50
San13-Dec-01 23:50 
QuestionWho have a example of setting a picture as background in CRichEditView? Pin
white jungle13-Dec-01 23:03
white jungle13-Dec-01 23:03 
GeneralDummy dialog! Pin
Rickard Andersson2013-Dec-01 22:03
Rickard Andersson2013-Dec-01 22:03 
GeneralRe: Dummy dialog! Pin
Eugene Pustovoyt13-Dec-01 23:35
Eugene Pustovoyt13-Dec-01 23:35 
GeneralRe: Dummy dialog! Pin
Nish Nishant13-Dec-01 23:47
sitebuilderNish Nishant13-Dec-01 23:47 
GeneralDLL questions Pin
13-Dec-01 19:51
suss13-Dec-01 19:51 
GeneralRe: DLL questions Pin
Nish Nishant13-Dec-01 20:10
sitebuilderNish Nishant13-Dec-01 20:10 
GeneralRe: DLL questions Pin
Joaquín M López Muñoz13-Dec-01 23:57
Joaquín M López Muñoz13-Dec-01 23:57 
GeneralRe: DLL questions Pin
Nemanja Trifunovic14-Dec-01 5:03
Nemanja Trifunovic14-Dec-01 5:03 
GeneralRe: DLL questions Pin
Joaquín M López Muñoz14-Dec-01 6:12
Joaquín M López Muñoz14-Dec-01 6:12 
GeneralRe: DLL questions Pin
Nemanja Trifunovic14-Dec-01 6:37
Nemanja Trifunovic14-Dec-01 6:37 
GeneralRe: DLL questions Pin
pba_14-Dec-01 6:40
pba_14-Dec-01 6:40 
GeneralRe: DLL questions Pin
Philip Patrick14-Dec-01 14:33
professionalPhilip Patrick14-Dec-01 14:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.