Thread View: net.micro.mac
2 messages
2 total messages
Started by Larry Hutchinson
Mon, 11 Mar 1985 18:44
HELP!! QD picture recording driving me crazy
Author: 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
Re: HELP!! QD picture recording driving me crazy
Author: Darin Adler
Date: Sat, 16 Mar 1985 05:46
Date: Sat, 16 Mar 1985 05:46
35 lines
1926 bytes
1926 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.
>
> 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);
>
> Larry Hutchinson, Tektronix, Inc. PO Box 500, MS Y6-546, Beaverton, OR 97077
> { decvax,allegra }!tektronix!tekcbi!larryh
It sounds like you have a ClipRect problem. When QD scales a picture, it
also scales the ClipRect. If I am not mistaken, this causes problems a lot
of the time, since the ClipRect is often set to -32768,-32768,32767,32767.
Try setting the ClipRect to something reasonable like the portRect.
This little "bug" drives me crazy, even when I know to expect it.
Darin Adler
ihnp4!tmq!darin
"Opinions expressed in this document not necessarily correct."
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads