Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!prlb2!kulcs!kulesat!esat!bartels From: bartels@haydn.kulesat.uucp Newsgroups: comp.sys.mac.programmer Subject: Help, greyvalue images on the Macintosh Summary: I just started to program in C on a Macintosh. I have some problems Keywords: colorquickdraw, C, greyvalueimages Message-ID: <991@haydn.kulesat.uucp> Date: 3 Apr 89 11:21:22 GMT Reply-To: bartels@kulesat.uucp Organization: Katholieke Universiteit Leuven,ESAT - dep. Elect. Engineering, Belgium Lines: 94 Dear Macintosh Users, I have some problems with writing a program in MPW-C to put a grey-value image on the screen. See here mine program: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef BitMap *BitMapPtr; main() { CWindowPtr ImagePort; CTabHandle CThan; Handle Image; Rect Imagerect; PixMapHandle ImageMap; int i; CWindowRecord wRecord; long int refCon; InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); /*opening a window for putting the image in*/ SetRect(&Imagerect,20,20,400,400); ImagePort = (CWindowPtr) NewCWindow((Ptr) &wRecord,&Imagerect, "Mijn eerste beeld",1,documentProc, (WindowPtr) -1 ,0,refCon = 4); /*intializing of color look up table*/ CThan = (CTabHandle) (NewHandle(255 * 4 + 10)); (*CThan)->ctSeed = GetCTSeed(); (*CThan)->ctFlags = 0; (*CThan)->ctSize = 256; for (i=1; i<=255; i++) {(*CThan)->ctTable[i].value = i; (*CThan)->ctTable[i].rgb.red = (short) (255 * i); (*CThan)->ctTable[i].rgb.green = (short) (255 * i); (*CThan)->ctTable[i].rgb.blue = (short) (255 * i);}; /* initializing of grey value image */ Image = NewHandle(128*128); for (i=0; i<=128*128-1; i++) {*(*Image + i) = (short)(i/255);} SetRect(&Imagerect,0,0,128,128); ImageMap = NewPixMap(); (*ImageMap)->baseAddr = *Image; (*ImageMap)->rowBytes = (0x8000|128); (*ImageMap)->bounds = Imagerect; (*ImageMap)->pmTable = CThan; CopyBits(((BitMapPtr)*ImageMap),((BitMapPtr)*(ImagePort->portPixMap)), &Imagerect,&Imagerect,0,0); } The program doesn't pass the line Image = NewHandle(128*128); except when I decrease the dimensions of the image to 28 * 28. With the little image there apears something on the screen but after running the program I had to restart the computer. Now I am searching for some example programs (I prefer C programs) to put greyvalue images on the Macintosh screen. Hoping someone can help me, I thank you to study mine problem Yours sincerly, Rudi Bartels KU Leuven Faculteit der Toegepaste Wetenschappen ESAT-MI2 Kard. Mercierlaan 94 3030 Heverlee Belgium email: bartels@kulesat.uucp Fax: 32-16-221855