📄 guiphotojob.c
字号:
/*
* Start of Zoran Standard Header
* Copyright (c) 2005, 2006 Zoran Corporation
*
*
* All rights reserved. Proprietary and confidential.
*
* DESCRIPTION for guiphotojob.c
* GUI action routine and support for launching a
* photoprint job.
*
* NEW HISTORY COMMENT (description must be followed by a blank line)
* <Enter change description here>
* ===== HISTORY of changes in //depot/imgeng/sw/se_gw/gui/guiphotojob.c
*
* 10/Jan/06 #3 dstrauss Set Default photoprinttype, not Current.
* Set proper paper size.
* 13/Dec/05 #2 dstrauss Pass brightness directly to
* addPhotoPrintImageToJob() without conversion.
* 13/Dec/05 #1 dstrauss Created.
*
*
* End of Zoran Standard Header
*/
#include "standard.h"
#include "propman.h"
#include "ts.h"
#include "ppjm.h"
#include "guiactions.h"
#include "guiproperties.h"
/*
* Pointer to the photoprint job control structure.
* NOTE that in this system there can be only one
* such job at a time!
*/
static PhotoPrintJob *theJob;
/*
* Convert UI brightness value (-100=dark, 100=light)
* to image processing brightness (-128 to 128)
*/
#define CVTBRIGHT(x) (((x)* 128)/100)
static PhotoPrintJob *CreatePhotoJob(Uint32 ImageNumber)
{
int success;
int maxW, maxH;
PhotoPrintAddImageStatus printImageStatus;
Uint32 displayW;
Uint32 displayH;
e_PhotoSize dispSize;
int printQuality;
Uint32 paperType;
int psize;
e_PaperSize paperSize;
int quality;
if (theJob) {
PSPRINTF("photoapp - job already active\n");
return (NULL);
}
theJob = createPhotoPrintJob(PPLT_AUTO_LAYOUT, JOB_PHOTOPRINT);
PSPRINTF("photoapp->created job %p\n", theJob);
if (!theJob) {
PSPRINTF("!!!! photoapp failed to create job %p\n");
return NULL;
}
// Set paper type
if (GPMGetSavedValue(GPID_PAPERTYPE) == GPID_PAPERTYPE_PHOTO) {
paperType = PTGLOSSY;
} else {
paperType = PTPLAIN;
}
OMsetEnum(omPHOTOPRINTTYPE, OMDEFAULT, paperType);
psize = GPMGetSavedValue(GPID_PAPERSIZE);
if (psize == GPID_PAPERSIZE_LETTER) {
PSPRINTF("photo outputpage = Letter\n");
paperSize = PS8p5x11;
} else {
PSPRINTF("photo outputpage = A4\n");
paperSize = PSA4;
}
/* NOTE - add handling for other paper sizes here */
setPhotoPrintJobPaperSize(theJob, paperSize);
// Set photo quality
quality = GPMGetSavedValue(GPID_QUALITY);
if ( quality == GPID_QUALITY_DRAFT ) {
printQuality = PQDRAFT;
} else if ( quality == GPID_QUALITY_NORMAL ) {
printQuality = PQNORMAL;
} else {
printQuality = PQPHOTO;
}
setPhotoPrintJobPrintQuality(theJob, printQuality);
maxW = 0;
maxH = 0;
// The result of crop rect conversion should be
// a number <= 1.0 (<= 65536 in the 16.16 fraction here).
// convert photo size code to w and h in millimeters*10
//
dispSize = (e_PhotoSize)GPMGetSavedValue(GPID_PHOTOSIZE);
getPhotoSizeDimensions10xmm(dispSize, &displayW, &displayH );
// HACK ALERT
//
// letter and A4 dont work printing on their native size because
// paper table mismatches, etc round funny so we hack down our
// own size here by a few pixels to accom.
//
if (dispSize == PHZ8p5x11 || dispSize == PHZA4) {
displayW -= 2;
displayH -= 2;
}
// convert photo extents to DPI space in photo job space (300 dpi)
//
displayW = (displayW * PHOTO_PRINT_COLOR_SPACE_DPI) / 254;
displayH = (displayH * PHOTO_PRINT_COLOR_SPACE_DPI) / 254;
success = 0;
printImageStatus =
addPhotoPrintImageToJob( theJob,
ImageNumber,/* image_number */
NULL, /* crop_rect */
GPMGetSavedValue(GPID_COPIES),
displayW, /* print width */
displayH, /* print height */
GPMGetSavedValue(GPID_BRIGHTNESS),/* brightness */
NULL, /* name_label */
NULL, /* time_label */
NULL /* comment_label */
);
switch (printImageStatus ) {
case PHOTO_PRINT_IMAGE_ACCEPTED:
// success
success = 1;
break;
case PHOTO_PRINT_IMAGE_DOES_NOT_FIT:
/* FIX ME -- switch to acknowledge screen? */
PSPRINTF("Image doesn't fit!!");
break;
case PHOTO_PRINT_IMAGE_OUT_OF_MEMORY:
/* FIX ME -- switch to acknowledge screen? */
PSPRINTF("Out of memory !!");
break;
default:
break;
}
if (!success) {
destroyPhotoPrintJob(theJob);
theJob = NULL;
}
return theJob;
}
//***********************************************************************
static void PhotoPrintEndCallback(PhotoPrintJob* pJob,
PhotoPrintJobStatus status)
{
destroyPhotoPrintJob(pJob);
if (pJob == theJob) {
theJob = NULL;
}
PSPRINTF("photojob %p done, current job is %p\n", pJob, theJob);
}
void GUIActionStartPhoto(int imageNumber, int color)
{
PhotoPrintJob * pJob;
// Set color/mono
PSPRINTF("photojob %s\n", color ? "Color" : "Mono");
OMsetEnum(omPRINTCOLOR, OMCURRENT, (color ? PCCOLOR : PCMONO));
// create a photo job with current selections
pJob = CreatePhotoJob(imageNumber);
// print it
if (pJob) {
int timeout, rv;
timeout = 0;
do {
// tell photo-app to start printing
rv = printPhotoPrintJob(pJob, PhotoPrintEndCallback);
if (!rv) {
// wait till current job is finished
// but not forever
timeout++;
TASKSLEEP_MILLISECONDS(333);
}
PSPRINTF("waiting for photojob\n");
} while( ! rv && timeout < 200 ); // 200 * .3 secs = 60 secs = 1 minute
PSPRINTF("photojob %s\n", rv ? "OK" : "FAILED TO START!!!!");
} else {
PSPRINTF("photojob already in progress\n");
}
}
void GUIActionStopPhoto()
{
if (theJob) {
cancelPhotoPrintJob(theJob);
}
theJob = NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -