Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!apple!well!crunch@well.sf.ca.us From: crunch@well.sf.ca.us (John Draper) Newsgroups: comp.sys.mac.programmer Subject: CopyBits Message-ID: <21789@well.sf.ca.us> Date: 22 Nov 90 05:56:56 GMT Sender: crunch@well.sf.ca.us Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 56 Does anyone know if it is possible to CopyBits from one off screen Pixmap to another one?? So far, nothing I have done has worked. I made sure the bounds to both are set the same, and the allocated memory for both are identical, but they have different buffers. The reason for this is so I can do scaling of the PixMaps. In this case, I want to scale the picture to a SMALLER size. So I set the following values. SetRect(&srcRect, 0, 0, 108, 128); /* Origional size */ SetRect(&destrect, 0, 0, 75, 100); /* Want scaled down to this size*/ I tried the following: srcPix is the source PixMap. destPix is the one I want to scale down into. destMap = NewPixMap(); /* To create a new Pixmap */ CopyPixMap(srcPix, destMap); /* To clone Ctab and other stuff*/ Before I copyBits, I want to allocate a buffer size at least the same size as the source buffer. I get this from RowBytes after masking off the hi bit of course. /*-------------------------------------------------------*/ /* I calculate the width using the recommended formula */ /* width is the scaled down width */ /*-------------------------------------------------------*/ xwidth = (((width * (**aPix).pixelSize) + 15) >> 4) << 1; srcBnds = (**srcPix).bounds; size = (long)xwidth * (long)(srcBnds.bottom - srcBnds.top); buff = NewPtr(size); (**destMap).baseAddr = buff; HLock(srcPix); HLock(destMap); CopyBits( *srcPix, /* Needs pointer, not handle */ *destMap, /* Same here */ &srcRect, /* Source is origional size */ &destrect, /* Dest is to be scaled down */ patCopy, /* Xfer mode */ 0L); /* No region */ HUnlock(srcPix); HUnlock(destMap); The "bounds" of both PixMaps are (0, 0, 108, 128). Is there anything Else I might have overlooked?? John D. Please respond to: crunch@well.sf.ca.us