static int mac_put_params(gx_device *dev, gs_param_list *plist) { gx_device_macos *mdev = (gx_device_macos *)dev; int isOpen = mdev->is_open; int code; int depth; gs_param_string outputFile; // Get the BitsPerPixel Parameter code = param_read_int(plist, "BitsPerPixel", &depth); if (!code) { code = mac_set_colordepth(dev, depth); if (code) param_return_error(plist, "BitsPerPixel", gs_error_rangecheck); } // Get OutputFile code = param_read_string(plist, "OutputFile", &outputFile); if (code < 0) { param_signal_error(plist, "OutputFile", code); return code; } else if (code == 0) { if (dev->LockSafetyParams && bytes_compare(outputFile.data, outputFile.size, (const byte *)mdev->outputFileName, strlen(mdev->outputFileName))) { param_signal_error(plist, "OutputFile", gs_error_invalidaccess); return gs_error_invalidaccess; } if (outputFile.size > (gp_file_name_sizeof - 1)) { param_signal_error(plist, "OutputFile", gs_error_limitcheck); return gs_error_limitcheck; } /* If filename changed, close file. */ if (outputFile.data != 0 && bytes_compare(outputFile.data, outputFile.size, (const byte *)mdev->outputFileName, strlen(mdev->outputFileName))) { /* Close the file if it's open. */ if (mdev->outputFile != NULL) { gx_device_close_output_file(dev, mdev->outputFileName, mdev->outputFile); memcpy(mdev->outputFileName, outputFile.data, outputFile.size); mdev->outputFileName[outputFile.size] = 0; gx_device_open_output_file(dev, mdev->outputFileName, true, true, &(mdev->outputFile)); } else { memcpy(mdev->outputFileName, outputFile.data, outputFile.size); mdev->outputFileName[outputFile.size] = 0; } } } // Get the Default Parameters mdev->is_open = 0; code = gx_default_put_params( dev, plist ); mdev->is_open = isOpen; return code; }
static int mac_open(register gx_device *dev) { gx_device_macos * mdev = (gx_device_macos *)dev; static short picHeader[42] = { 0x0000, // picture size 0x0000, 0x0000, 0x0318, 0x0264, // bounding rect at 72dpi 0x0011, 0x02ff, 0x0c00, 0xfffe, 0x0000, // version/header opcodes 0x0048, 0x0000, // best x resolution 0x0048, 0x0000, // best y resolution 0x0000, 0x0000, 0x0318, 0x0264, // optimal src rect at 72dpi 0x0000, // reserved 0x0000, 0x001e, // DefHilite 0x0008, 0x0048, // PenMode 0x001a, 0x0000, 0x0000, 0x0000, // RGBFgCol = Black 0x001b, 0xFFFF, 0xFFFF, 0xFFFF, // RGBBkCol = White 0x0001, 0x000A, // set clipping 0x0000, 0x0000, 0x0318, 0x0264, // clipping rect 0x0032, 0x0000, 0x0000, 0x0318, 0x0264 // erase rect }; mac_set_colordepth(dev, mdev->color_info.depth); mdev->numUsedFonts = 0; mdev->lastFontFace = -1; mdev->lastFontSize = -1; mdev->lastFontID = -1; mdev->pic = (PicHandle) NewHandle(500000); if (mdev->pic == 0) // error, not enough memory return gs_error_VMerror; HLockHi((Handle) mdev->pic); // move handle high and lock it mdev->currPicPos = (short*) *mdev->pic; memcpy(mdev->currPicPos, picHeader, 42*2); mdev->currPicPos += 42; // enter correct dimensions and resolutions ((short*)(*mdev->pic))[ 3] = mdev->MediaSize[1]; ((short*)(*mdev->pic))[ 4] = mdev->MediaSize[0]; ((short*)(*mdev->pic))[16] = ((short*)(*mdev->pic))[35] = ((short*)(*mdev->pic))[40] = mdev->height; ((short*)(*mdev->pic))[17] = ((short*)(*mdev->pic))[36] = ((short*)(*mdev->pic))[41] = mdev->width; ((short*)(*mdev->pic))[10] = (((long) X2Fix( mdev->x_pixels_per_inch )) & 0xFFFF0000) >> 16; ((short*)(*mdev->pic))[11] = ((long) X2Fix( mdev->x_pixels_per_inch )) & 0x0000FFFF; ((short*)(*mdev->pic))[12] = (((long) X2Fix( mdev->y_pixels_per_inch )) & 0xFFFF0000) >> 16; ((short*)(*mdev->pic))[13] = ((long) X2Fix( mdev->y_pixels_per_inch )) & 0x0000FFFF; // finish picture, but dont increment pointer, we want to go on drawing *mdev->currPicPos = 0x00ff; // notify the caller that a new device was opened if (pgsdll_callback) (*pgsdll_callback) (GSDLL_DEVICE, (char *)mdev, 1); return 0; }