Article View: net.micro.mac
Article #807HELP!! QD picture recording driving me crazy
From: Larry Hutchinson
Date: Mon, 11 Mar 1985 18:44
Date: Mon, 11 Mar 1985 18:44
230 lines
6570 bytes
6570 bytes
Could some kind person please peruse the following code fragment and
tell me what I am doing wrong? I have read QuickDraw(3-2-83) and the
Scrap Manager(11-16-83) about four zillion times without finding a
clue.
Incidentally, what I was trying to do in the first place (before the
folloing problem ruined my whole weekend) was to find out how to make
a PICT scrap to reproduce a rectangular chunk out of a random array
of bits in a bitmap (apropos of my LIFE prgm). Does anyone know how
MacPaint does clipping? CopyBits perhaps? The following just uses simple
line drawing to keep it simple.
glorpRect=TestRect;
pHndl=OpenPicture(&TestRect);
MoveTo(pass(topLeft(TestRect))); /* a few random */
LineTo(pass(botRight(TestRect))); /* lines and */
FrameOval(&TestRect); /* ovals and */
MoveTo(0,0); LineTo(100,100); /* other such stuff*/
ClosePicture();
/* if the glorpRect is changed to any size not equal to TestRect */
/* then the following DrawPicture will not work. */
InsetRect(&glorpRect,0,0); /* try any non-zero value! */
DrawPicture(pHndl,&glorpRect);
The problem is that DrawPicture will work just fine if the rectangle
for drawing is exactly the same as the one used for recording, but if
it is not (via InsetRect for example), nothing occurs on the screen.
The problem appears to be in the recording or the setup for the
recording as I can display PICT clippings just fine in any size rect
(see program text below). An additional clue is that the scrapbook
DA complains about my clipping by printing "Picture is too large to
display here". Pasting into MacPaint gives a correct sized marquee but
with nothing in it! Clearly the scaling is all screwed up.
I am including the following source for two reasons: (1) in case the
problem isn't local to the above fragment & (2) it might be usefull
to someone as a skeleton test bed.
Larry Hutchinson, Tektronix, Inc. PO Box 500, MS Y6-546, Beaverton, OR 97077
(503)-627-8361 (office)
{ decvax,allegra }!tektronix!tekcbi!larryh
/*
* a test ... written in Aztec C
*/
#include "quickdraw.h"
#include "menu.h"
#include "window.h"
#include "event.h"
#include "desk.h"
#include "inits.h"
#include "dialog.h"
#include "resource.h"
#include "scrap.h"
#include "memory.h"
#define NIL 0L
#define appleMenu 1
#define fileMenu 256
#define editMenu 257
#define ctrlMenu 258
#define lastMenu 4
PicHandle pHndl;
long pOffset;
MenuHandle myMenus[lastMenu];
Rect screenRect, dragRect, pRect,TestRect,glorpRect;
WindowRecord wRecord;
WindowPtr myWindow, whichWindow;
EventRecord myEvent;
main()
{
char temp;
int code,i;
InitGraf(&thePort);
InitFonts();
FlushEvents(everyEvent, 0);
InitWindows();
setupmenu();
InitDialogs(0L);
InitCursor();
screenRect = screenBits.bounds;
SetRect(&dragRect, 4, 24, screenRect.right-4, screenRect.bottom-4);
SetRect(&TestRect, 10,10,200,100);
SetRect(&pRect, 40, 50, 450, 300);
myWindow = NewWindow(&wRecord, &pRect, ctop("test"),
0x100, 0, -1L, 0, 0L);
SetPort(myWindow);
pRect = thePort->portRect;
for (;;) {
SystemTask();
temp = GetNextEvent(everyEvent, &myEvent);
switch(myEvent.what) {
case mouseDown:
code = FindWindow(pass(myEvent.where), &whichWindow);
switch (code) {
case inMenuBar:
docommand(MenuSelect(pass(myEvent.where)));
break;
case inSysWindow:
SystemClick(&myEvent, whichWindow);
break;
case inGrow:
case inContent:
if (whichWindow != FrontWindow())
SelectWindow(whichWindow);
else {
GlobalToLocal(&myEvent.where);
}
break;
}
break;
case keyDown:
case autoKey:
break;
case activateEvt:
if (myEvent.modifiers&1)
;
break;
case updateEvt:
SetPort(myWindow);
BeginUpdate(myWindow);
EndUpdate(myWindow);
break;
case nullEvent:
break;
}
}
}
docommand(mResult)
unsigned long mResult;
{
char name[30];
short theMenu, theItem,itemHit;
theMenu = mResult >> 16;
theItem = mResult;
switch(theMenu) {
case appleMenu:
GetItem(myMenus[0], theItem, name);
OpenDeskAcc(name);
break;
case fileMenu:
_exit();
case editMenu:
if (!SystemEdit(theItem-1)) {
switch(theItem) {
case 3: /* Cut */
break;
case 4: /* Copy */
/* this is the offending code ! */
glorpRect=TestRect;
pHndl=OpenPicture(&TestRect);
MoveTo(pass(topLeft(TestRect)));
LineTo(pass(botRight(TestRect)));
FrameOval(&TestRect);
MoveTo(0,0); LineTo(100,100);
ClosePicture();
/* if the glorpRect is changed to any size not equal to TestRect */
/* then the following DrawPicture will not work. */
InsetRect(&glorpRect,0,0); /* try any non-zero value!*/
DrawPicture(pHndl,&glorpRect);
HLock(pHndl);
ZeroScrap();
PutScrap(GetHandleSize(pHndl),'PICT',*pHndl);
HUnlock(pHndl);
KillPicture(pHndl);
break;
case 5: /* Paste */
pHndl= NewHandle(0L);
if (GetScrap(pHndl,'PICT',&pOffset) > 0){
DrawPicture(pHndl,&TestRect);
}
DisposHandle(pHndl);
break;
}
}
break;
case ctrlMenu:
switch(theItem){
case 1:
EraseRect(&pRect);
break;
}
break;
}
HiliteMenu(0);
}
setupmenu()
{
int i;
InitMenus();
myMenus[0] = NewMenu(appleMenu, ctop("\024"));
AddResMenu(myMenus[0], 'DRVR');
myMenus[1] = NewMenu(fileMenu, ctop("File"));
AppendMenu(myMenus[1], ctop("Quit"));
myMenus[2] = NewMenu(editMenu, ctop("Edit"));
AppendMenu(myMenus[2], ctop("Undo(;-------(;Cut;Copy;Paste"));
myMenus[3] = NewMenu(ctrlMenu, ctop("Control"));
AppendMenu(myMenus[3], ctop("Clear"));
for (i=0;i<lastMenu;i++)
InsertMenu(myMenus[i], 0);
DrawMenuBar();
}
--
Larry Hutchinson, Tektronix, Inc. PO Box 500, MS Y6-546, Beaverton, OR 97077
{ decvax,allegra }!tektronix!tekcbi!larryh
Technical Details
Message-ID:
<193@tekcbi.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!tektronix!tekig!tekcbi!larryhShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site tekcbi.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!tektronix!tekig!tekcbi!larryh From: larryh@tekcbi.UUCP (Larry Hutchinson) Newsgroups: net.micro.mac Subject: HELP!! QD picture recording driving me crazy Message-ID: <193@tekcbi.UUCP> Date: Mon, 11-Mar-85 13:44:50 EST Article-I.D.: tekcbi.193 Posted: Mon Mar 11 13:44:50 1985 Date-Received: Thu, 14-Mar-85 04:01:38 EST Organization: Tektronix, Beaverton OR Lines: 230