BOOL CExpandImageDlg::PreDoModal (LPVOID lpVoid) { LPIMAGE lpImage = NULL; LPFRAME lpFrame; if(lpImage = GetImage()) { lpFrame = ImgGetBaseEditFrame(lpImage); m_Units = m_SaveUnits = Control.Units; m_Crop.top = m_Crop.left = 0; m_Crop.right = lpImage->npix - 1; m_Crop.bottom = lpImage->nlin - 1; m_Resolution = m_CropResolution = m_OrigResolution = FrameResolution(lpFrame); m_Depth = FrameDepth(lpFrame); } else { m_Resolution = m_CropResolution = 75; m_Depth = 1; } m_Width = m_OrigWidth = FGET(m_Crop.right - m_Crop.left + 1, m_CropResolution); m_Height = m_OrigHeight = FGET(m_Crop.bottom - m_Crop.top + 1, m_CropResolution); m_Left = m_Top = 0; m_FillColor.gray = 255; return CPPViewModalDlg::PreDoModal(); }
VOID CSizeImageDlg::DoSizeInits( ) { HWND hDlg = GetSafeHwnd(); LPFRAME lpFrame; LPIMAGE lpImage = GetImage(); FRMDATATYPE Type = FDT_RGBCOLOR; ImgGetInfo(lpImage, NULL, NULL, NULL, &Type); /* Be careful to set all values before doing a SetDlg... with them */ /* The Edit structure is a temorary holding area for sizing dialog boxes */ m_Distortable = NO; m_MaintainSize = NO; m_ScaleX = m_ScaleY = 100; if ( lpImage ) { lpFrame = ImgGetBaseEditFrame(lpImage); m_Crop.left = m_Crop.top = 0; m_Crop.right = lpImage->npix - 1; m_Crop.bottom = lpImage->nlin - 1; m_Resolution = m_CropResolution = m_OrigResolution = FrameResolution(lpFrame); m_Depth = FrameDepth(lpFrame); } else { m_Resolution = m_CropResolution = 75; m_Depth = 1; } m_Angle = 0; m_Width = FGET( CROPWIDTH(), m_CropResolution ); m_Height = FGET( CROPHEIGHT(), m_CropResolution ); CheckDlgButton( IDC_DISTORT, m_Distortable); CheckDlgButton( IDC_SMARTSIZE, m_SmartSize ); CheckDlgButton( IDC_MAINTAINSIZE, m_MaintainSize ); ControlEnable(hDlg, IDC_DISTORT, !m_MaintainSize); ControlEnable(hDlg, IDC_MAINTAINSIZE, !m_Distortable ); ControlEnable( hDlg, IDC_SMARTSIZE, !m_MaintainSize && !m_Distortable && CANDOTRANSPARENCY(Type)); InitDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES, 0L, FGET(9999,1) ); InitDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES, 0L, FGET(9999,1) ); InitDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, YES, 1, 10000 ); InitDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, YES, 1, 10000 ); InitDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO, 1, 10000 ); ImageMemory( hDlg, IDC_MEMORY, m_Width, m_Height, m_Resolution, m_Depth ); CheckComboItem(hDlg, IDC_PREF_UNITS, IDC_PREF_UNITFIRST, IDC_PREF_UNITLAST, m_Units); SetUnitLabels(); }
void CChromaMask::MaskAddChroma(LPIMAGE lpImage, LPMASK lpMask, LPRECT lpRect, BOOL MaskExist) { int dx, dy, i, depth; LPTR lpAlphaLine; LPTR lpLine; LPOBJECT lpBase = ImgGetBase(lpImage); int top = -1; int bottom = 0; FRMTYPEINFO TypeInfo; ProgressBegin(1,PROGRESS_ID(IDS_CHROMA_APPLY)); PixmapGetInfo(&lpMask->Pixmap, PMT_EDIT, &dx, &dy, NULL, NULL); ImgGetTypeInfo(lpImage, &TypeInfo); if (!(depth = FrameDepth(ObjGetEditFrame(lpBase)))) depth = 1; // never worry about lineart xExtL = 10000; xExtR = 0; lpLine = Alloc((long)dx*depth); for (i = 0; i < dy; ++i) { AstralClockCursor(i, dy, NO); Dirty = FALSE; lpAlphaLine = PixmapPtr( &lpMask->Pixmap, PMT_EDIT, 0, i, YES); if (Delete) clr(lpAlphaLine, dx); ImgGetLine(lpImage, lpBase, 0, i, dx, lpLine, NULL); ChromaProc(dx, TypeInfo, lpLine, lpAlphaLine, MaskExist); if (Dirty) { if (top == -1) top = i; if (i > bottom) bottom = i; } } lpRect->left = xExtL; lpRect->right = xExtR; lpRect->top = top; lpRect->bottom = bottom; FreeUp(lpLine); ProgressEnd(); }
BOOL ExportImageDLL( LPSTR lpExportFile ) { HMODULE hModule; FARPROC lpClockCursor = NULL; FARPROC lpDataPointer = NULL; EXPORTPROC lpStartProc; EXPORTPROC lpProcessProc; EXPORTPROC lpEndProc; LPFRAME lpFrame; EXPPARMS parms; BOOL fSuccess = FALSE; LPIMAGE lpImage; lpImage = GetActiveImage(); if (!lpImage) goto Exit; lpFrame = ImgGetBaseEditFrame(lpImage); if (!lpFrame) goto Exit; if (!(hModule = (HMODULE)AstralLoadLibrary(lpExportFile))) goto Exit; lpStartProc = (EXPORTPROC)GetProcAddress(hModule, "_ExportStart"); lpProcessProc = (EXPORTPROC)GetProcAddress(hModule, "_ExportProcess"); lpEndProc = (EXPORTPROC)GetProcAddress(hModule, "_ExportEnd"); if ( !lpStartProc || !lpProcessProc || !lpEndProc ) goto Exit; iExportXSize = FrameXSize( lpFrame ); iExportYSize = FrameYSize( lpFrame ); iExportDepth = FrameDepth( lpFrame ); iExportResolution = FrameResolution( lpFrame ); lpClockCursor = MakeProcInstance( (FARPROC)ExportClockCursor, PictPubApp.Get_hInstAstral() ); lpDataPointer = MakeProcInstance( (FARPROC)ExportDataPointer, PictPubApp.Get_hInstAstral() ); AllocLines( &lpExportBuffer, 1, iExportXSize, max(1, iExportDepth)); parms.hInstance = PictPubApp.Get_hInstAstral(); parms.hWnd = GetActiveWindow(); parms.lpszFileName = lpImage->CurFile; parms.XSize = iExportXSize; parms.YSize = iExportYSize; parms.Depth = iExportDepth; parms.Resolution = iExportResolution; parms.StatusCallback = (LPROC)lpClockCursor; parms.DataPointer = (LPTRPROC)lpDataPointer; if (!lpClockCursor || !lpDataPointer || !lpExportBuffer) goto Exit; if ((*lpStartProc)((LPEXPPARMS)&parms)) { MessageStatus( IDS_PLEASEWAIT ); if ((*lpProcessProc)((LPEXPPARMS)&parms)) { fSuccess = TRUE; (*lpEndProc)((LPEXPPARMS)&parms); } } Exit: if (lpClockCursor) FreeProcInstance((FARPROC)lpClockCursor); if (lpDataPointer) FreeProcInstance((FARPROC)lpDataPointer); if (lpExportBuffer) FreeUp(lpExportBuffer); lpExportBuffer = NULL; if (hModule) FreeLibrary(hModule); MessageStatus( 0 ); return(fSuccess); }
BOOL CombineObjObjects( LPIMAGE lpImage, LPCMD_PARMS lpCmdParms ) /************************************************************************/ { RECT rCombine,r; LPOBJECT lpBase, lpObj; LPALPHA lpAlpha, lpMask; LPFRAME lpDFrame, lpSFrame; LPTR lpDF, lpDM, *lpSM, *lpSF; int x, y, yy, depth; int N, H, W, i; double *lpAlphaTable, *AiXOi; double red,blue,green,k; POINT pt; double Oi, Ai, Mi, Mc; LPOBJECT *lpObject; FRMTYPEINFO TypeInfo; BOOL fCanDoOpacity; FRMDATATYPE MaskType = FDT_GRAYSCALE; if (!(lpImage)) return( FALSE ); ImgGetTypeInfo(lpImage, &TypeInfo); if (TypeInfo.DataType == FDT_LINEART && Mask.OneBitMask) MaskType = FDT_LINEART; fCanDoOpacity = CANDOTRANSPARENCY(TypeInfo.DataType); lpObj = lpBase = ImgGetBase(lpImage); if (!(depth = FrameDepth(ObjGetEditFrame(lpBase)))) depth = 1; // never worry about lineart N = ImgCountSelObjects(lpImage, NULL); ImgGetSelObjectRect(lpImage, &rCombine, YES); H = RectHeight(&rCombine); W = RectWidth (&rCombine); lpObject = NULL; AiXOi = lpAlphaTable = NULL; lpAlphaTable = (double *)Alloc((N+1) * sizeof(double)); AiXOi = (double *)Alloc(N * sizeof(double)); lpSM = (LPTR *)Alloc(N * sizeof(LPTR)); lpSF = (LPTR *)Alloc(N * sizeof(LPTR)); lpObject = (LPOBJECT *)Alloc(N * sizeof(LPOBJECT)); lpAlpha = MaskCreate(NULL, W, H, YES, Control.NoUndo, MaskType); lpDFrame = ImgGetBaseEditFrame(lpImage); lpDFrame = FrameOpen(FrameType(lpDFrame), W, H, FrameResolution(lpDFrame)); if (!lpAlphaTable || !lpObject || !AiXOi || !lpAlpha || !lpDFrame || !lpSM || !lpSF) { if (lpAlphaTable) FreeUp(lpAlphaTable); if (lpObject) FreeUp(lpObject); if (AiXOi) FreeUp(AiXOi); if (lpDFrame) FreeUp(lpDFrame); if (lpSF) FreeUp(lpSF); if (lpSM) FreeUp(lpSM); Message(IDS_EMEMALLOC); return(FALSE); } for (i=0; i < N; i++) lpObj = lpObject[i] = ImgGetSelObject(lpImage, lpObj); ImgEditInit(lpImage, ET_OBJECT, UT_DELETEOBJECTS, lpBase); ProgressBegin(1, PROGRESS_ID(IDS_UNDOOBJCOMBOBJS)); for (y = 0; y <= H; y++) { AstralClockCursor(y, H, NO); lpDF = FramePointer(lpDFrame, 0, y, YES); lpDM = PixmapPtr(&lpAlpha->Pixmap, PMT_EDIT, 0, y, YES); pt.y = y + rCombine.top; for (i=0; i < N; i++) { yy = pt.y - lpObject[i]->rObject.top; lpSFrame = ObjGetEditFrame(lpObject[i]); lpSF[i] = FramePointer(lpSFrame, 0, yy, NO); lpMask = ObjGetAlpha(lpObject[i]); lpSM[i] = PixmapPtr(&lpMask->Pixmap, PMT_EDIT, 0, yy, NO); } for (x = 0; x < W; x++) { lpAlphaTable[N] = 1.0; pt.x = x + rCombine.left; for (i=N-1; i >= 0; i--) { r = lpObject[i]->rObject; r.bottom++; r.right++; if (PtInRect(&r, pt)) { if (fCanDoOpacity) Oi = lpObject[i]->Opacity / 255.0; else Oi = 1; if (fCanDoOpacity) Ai = *lpSM[i]++ / 255.0; else if (*lpSM[i] < 128) { Ai = 0; lpSM[i]++; } else { Ai = 1; lpSM[i]++; } AiXOi[i] = Oi * Ai; lpAlphaTable[i] = lpAlphaTable[i+1] * (1.0 - AiXOi[i]); } else { AiXOi[i] = 1.0; lpAlphaTable[i] = lpAlphaTable[i+1]; } } Mc = 1.0 - lpAlphaTable[0]; lpDM[x] = (BYTE)(Mc * 255); red = blue = green = k = 0; for (i=0; i < N; i++) { r = lpObject[i]->rObject; r.bottom++; r.right++; if (PtInRect(&r, pt)) { Mi = AiXOi[i] * lpAlphaTable[i+1]; switch(depth) { case 1: red += *lpSF[i]++ * Mi; break; case 3: red += *lpSF[i]++ * Mi; green += *lpSF[i]++ * Mi; blue += *lpSF[i]++ * Mi; break; case 4: red += *lpSF[i]++ * Mi; green += *lpSF[i]++ * Mi; blue += *lpSF[i]++ * Mi; k += *lpSF[i]++ * Mi; break; } } } if (Mc == 0.0) Mc = 1.0; switch(depth) { case 1: *lpDF++ = (BYTE)(red / Mc); break; case 3: *lpDF++ = (BYTE)(red / Mc); *lpDF++ = (BYTE)(green / Mc); *lpDF++ = (BYTE)(blue / Mc); break; case 4: *lpDF++ = (BYTE)(red / Mc); *lpDF++ = (BYTE)(green / Mc); *lpDF++ = (BYTE)(blue / Mc); *lpDF++ = (BYTE)(k / Mc); break; } } } lpObj = ObjCreateFromFrame(ST_PERMANENT, lpDFrame, lpAlpha, &rCombine, Control.NoUndo ); lpObj->fSelected = YES; lpObj->fUndoDeleted = YES; ImgAddNewObject(lpImage, lpObj); for (i=0; i < N; i++) lpObject[i]->fDeleted = YES; ImgEditedObject(lpImage, lpBase, IDS_UNDOOBJCOMBOBJS, NULL); UpdateImage(lpImage, &rCombine, YES); FreeUp(lpSM); FreeUp(lpSF); FreeUp(AiXOi); FreeUp(lpAlphaTable); FreeUp(lpObject); ProgressEnd(); return( TRUE ); }
BOOL ObjGetLine(LPOBJECT lpObject, int x, int y, int dx, LPTR lpOut) /************************************************************************/ { LPALPHA lpAlpha; LPTR lp; LPPROCESSPROC lpProcessProc; RECT rLine, rSect; int nPixels, ox, oy, depth; FRMTYPEINFO TypeInfo; FRMDATATYPE DataType; long lOffset; LPFRAME lpFrame; // fill buffer with base image object // use depth of base image object lpFrame = ObjGetEditFrame(lpObject); FrameGetTypeInfo(lpFrame, &TypeInfo); DataType = TypeInfo.DataType; depth = FrameDepth(lpFrame); if (TypeInfo.DataType == FDT_LINEART) { depth = 1; TypeInfo.DataType = FDT_GRAYSCALE; } if (!ObjGetLineAlloc(dx, depth)) { //Message(IDS_EMEMALLOC); return(FALSE); } if (!FrameRead(lpFrame, x, y, dx, lpOut, dx)) return(FALSE); // setup rect for this line for intersect check rLine.left = x; rLine.right = x + dx - 1; rLine.top = rLine.bottom = y; // start with first object on top of base image while(lpObject = lpObject->lpNext) { // if object cannot be rendered through raster means if (lpObject->fDeleted || !AstralIntersectRect(&rSect, &lpObject->rObject, &rLine)) continue; // get merge proc for this object lpProcessProc = GetProcessProc(lpObject->MergeMode, DataType); ox = rSect.left-lpObject->rObject.left; oy = y-lpObject->rObject.top; nPixels = (rSect.right - rSect.left + 1); lOffset = (long)(rSect.left - rLine.left) * depth; lp = FramePointer(ObjGetEditFrame(lpObject), ox, oy, NO, nPixels); if (lp) { if (lpAlpha = ObjGetAlpha(lpObject)) { MaskLoad(lpAlpha, ox, oy, nPixels, lpGLMaskBuf); if (lpObject->Opacity != 255) ScaleData8(lpGLMaskBuf, nPixels, lpObject->Opacity); } else set(lpGLMaskBuf, nPixels, lpObject->Opacity); (*lpProcessProc)(lpOut+lOffset, lp, lpGLMaskBuf, nPixels); } } return(TRUE); }
BOOL ConvertImage(LPIMAGE lpImage, LPCONVERT_PARMS lpParms) /***********************************************************************/ { BOOL fRet = FALSE; LPFRAME lpDstFrame, lpBaseFrame; LPOBJECT lpBase, lpObject; BOOL fError, fOptimize, fProgressSet; INTERNAL_DATA data; int inDepth, iMaxWidth, nColors, i; LPCOLORMAP lpColorMap; LPRGB lpRGB; FRMTYPEINFO InTypeInfo, OutTypeInfo; CFrameTypeConvert TypeConvert; DITHER_TYPE DitherType = DT_DEFAULT; if (ImgInMaskEditMode(lpImage)) return(TRUE); lpColorMap = NULL; lpBase = ImgGetBase(lpImage); lpBaseFrame = ObjGetEditFrame(lpBase); inDepth = FrameDepth(lpBaseFrame); OutTypeInfo = lpParms->cmsInfo.dst; FrameGetTypeInfo(lpBaseFrame, &InTypeInfo); // are we try to convert to a color managed image? if (Control.CMSEnabled && IsDstPTSelected(&OutTypeInfo.ptInfo)) { // see if our image already has a color managed source if (!IsSrcPTSelected(&InTypeInfo.ptInfo)) { // nope, see if the source passed in is valid for this image if (IsSrcPTSelected(&lpParms->cmsInfo.src.ptInfo) && (lpParms->cmsInfo.src.DataType == InTypeInfo.DataType)) { InTypeInfo = lpParms->cmsInfo.src; } // go get a source from the user else { CMSINFO CmsInfo2; if( CmsGetSrcPTType( &InTypeInfo, &CmsInfo2) ) InTypeInfo = CmsInfo2.src; } } } else FrameSetTypeInfo(&InTypeInfo, InTypeInfo.DataType, InTypeInfo.ColorMap); // no conversion necessary if (FrameTypeInfoEqual(InTypeInfo, OutTypeInfo)) return(TRUE); DitherType = lpParms->DitherType; fOptimize = lpParms->ConvertType == CT_OPTIMIZED; fProgressSet = FALSE; if ( OutTypeInfo.DataType == FDT_PALETTECOLOR/* && inDepth >= 3 */) { if (lpParms->ConvertType == CT_CUSTOM) { FNAME szFileName; if ( !LookupExtFileN( lpParms->szPalette, szFileName, IDN_PALETTE, NO ) ) return(FALSE); if (!(lpColorMap = Palette_ReadColorMap(szFileName))) return(FALSE); } else { // allocate a map to carry around with image lpColorMap = FrameCreateColorMap(); if (!lpColorMap) { Message(IDS_EMEMALLOC); goto MemError; } lpColorMap->NumEntries = lpParms->iLevels; if (InTypeInfo.DataType == FDT_GRAYSCALE && lpColorMap->NumEntries == 256 && fOptimize) { DitherType = DT_NONE; lpRGB = lpColorMap->RGBData; for (i = 0; i < lpColorMap->NumEntries; ++i) { lpRGB->red = lpRGB->green = lpRGB->blue = i; ++lpRGB; } } else { // 1. CreateOptimizedPalette phase - only if fOptimize // 2. Mapping phase ProgressBegin(fOptimize ? 2 : 1, lpParms->Common.idDirty-IDS_UNDOFIRST+IDS_PROGFIRST); fProgressSet = TRUE; if (fOptimize) ProgressBegin(1, 0); if (!CreateOptimizedPalette(lpBase, ObjGetEditFrame(lpBase), lpColorMap->RGBData, &lpColorMap->NumEntries, fOptimize, fOptimize ? AstralClockCursor : NULL)) { if (fOptimize) ProgressEnd(); Message(IDS_EMEMALLOC); goto ExitFalse; } if (fOptimize) ProgressEnd(); } } if (lpColorMap->NumEntries <= 16) lpColorMap->NumEntries = 16; else lpColorMap->NumEntries = 256; FrameSetTypeInfo(&OutTypeInfo, FDT_PALETTECOLOR, lpColorMap); } if (!fProgressSet) ProgressBegin(1, lpParms->Common.idDirty-IDS_UNDOFIRST+IDS_PROGFIRST); fProgressSet = TRUE; iMaxWidth = 0; lpObject = NULL; while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO)) { if (RectWidth(&lpObject->rObject) > iMaxWidth) iMaxWidth = RectWidth(&lpObject->rObject); } if (!TypeConvert.Init(InTypeInfo, OutTypeInfo, iMaxWidth, DitherType)) { Message(IDS_EMEMALLOC); goto ExitFalse; } if (ImgMultipleObjects(lpImage)) { ProgressBegin(ImgCountObjects(lpImage), 0); if ( !ImgEditInit(lpImage, ET_ALLOBJECTS, UT_NEWDATA|UT_COLORMAP, lpBase) ) goto ExitFalse; fError = NO; lpObject = NULL; while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO)) { lpDstFrame = ConvertFrame(ObjGetEditFrame(lpObject), OutTypeInfo, &TypeConvert); if (!lpDstFrame) { fError = YES; break; } ImgEditedObjectFrame( lpImage, lpObject, lpParms->Common.idDirty, NULL, lpDstFrame, NULL); } if (fError) { lpObject = NULL; while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO)) { if (lpObject->Pixmap.UndoFrame) { lpDstFrame = lpObject->Pixmap.EditFrame; lpObject->Pixmap.EditFrame = lpObject->Pixmap.UndoFrame; lpObject->Pixmap.UndoFrame = NULL; FrameClose(lpDstFrame); } } } ProgressEnd(); } else { if ( !ImgEditInit(lpImage, ET_OBJECT, UT_NEWDATA|UT_COLORMAP, lpBase) ) goto ExitFalse; ProgressBegin(1, 0); lpDstFrame = ConvertFrame(lpBaseFrame, OutTypeInfo, &TypeConvert); ProgressEnd(); if (!lpDstFrame) goto ExitFalse; /* Setup the new image and bring up the new image window */ ImgEditedObjectFrame( lpImage, lpBase, lpParms->Common.idDirty, NULL, lpDstFrame, NULL); } switch (lpParms->cmsInfo.dst.DataType) { case FDT_LINEART: lpImage->DataType = IDC_SAVELA; break; case FDT_GRAYSCALE: lpImage->DataType = IDC_SAVECT; break; case FDT_PALETTECOLOR: lpImage->DataType = IDC_SAVE8BITCOLOR; break; case FDT_RGBCOLOR: lpImage->DataType = IDC_SAVE24BITCOLOR; break; case FDT_CMYKCOLOR: lpImage->DataType = IDC_SAVE32BITCOLOR; break; } ImgColorMapChanged(lpImage); lpParms->Common.UpdateType = UT_DATATYPE; fRet = TRUE; ExitFalse: if (fProgressSet) ProgressEnd(); MemError: if (lpColorMap) FrameDestroyColorMap(lpColorMap); return(fRet); }
long DoOpenDlg( /************************************************************************/ HWND hDlg, int idDlg, WORD idType, LPSTR pFileNameOut, BOOL fSavingIn) { int iReturn; FNAME szExtension, szStartDir; int iStartDrive; fSaving = fSavingIn; idDataType = NULL; bImageOpen = idDlg == IDD_OPEN || idDlg == IDD_SAVEAS; idFileType = idType; if (bImageOpen) { idFileType = bound(idFileType, IDN_ART, IDN_BMP); if (fSaving) { if (!Readers[idFileType-IDN_ART].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))]) idFileType = IDN_ART; } else { if (!Readers[idFileType-IDN_ART].bOpen) idFileType = IDN_ART; } } fUntitled = lpImage && lpImage->fUntitled; if (bImageOpen && fSaving && !fUntitled) { lstrcpy( szSaveName, pFileNameOut ); lstrcpy( szFileSpec, pFileNameOut ); stripfile( szFileSpec ); FixPath( szFileSpec ); LookupExtension( idFileType, szExtension ); lstrcat( szFileSpec, szExtension ); } else { GetFileLocation( idFileType, szFileSpec ); } /* Initialize some values used in DlgOpenProc */ wFileAttr = 0; iStartDrive = CURRENTDRIVE; CURRENTDIR( szStartDir, sizeof(FNAME) ); idOpen = 0; do { if (idOpen) idDlg = idOpen; else idOpen = idDlg; iReturn = AstralDlg( NO|2, hInstAstral, hDlg, idDlg, DlgOpenProc ); } while (idOpen != idDlg); CHDRIVE( iStartDrive ); //CHDIR( szStartDir ); if ( !iReturn ) { pFileNameOut[0] = '\0'; return( NULL ); } lstrcpy( pFileNameOut, szFileSpec ); SetFileLocation( idFileType, szFileSpec ); return( MAKELONG( idFileType, idDataType ) ); }
BOOL WINPROC EXPORT DlgOpenProc( /************************************************************************/ HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL Bool; ITEMID id; WORD wMsg, wIndex; int i, ii, l, fp, hi, lo; FNAME szDriveNDir, szFileName, szExtension; HMENU hMenu; STRING szString; char cChar; BOOL bModifySaveName; static BOOL bDisableCancel; switch (msg) { case WM_INITDIALOG: SET_CLASS_HBRBACKGROUND(hDlg, ( HBRUSH )GetStockObject(LTGRAY_BRUSH)); CenterPopup( hDlg ); if ( !DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr) ) { lstrcpy( szFileSpec, lstrchr( szFileSpec, '*' ) ); DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr); } SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving); CheckComboItem( hDlg, IDC_FILETYPES, IDC_ART, IDC_BMP, IDC_ART + (idFileType-IDN_ART) ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_LIMITTEXT, MAX_FNAME_LEN-1, 0L); LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, NO ); CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath ); CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed ); for (i = IDC_ART; bImageOpen && i <= IDC_BMP; ++i) { ii = i-IDC_ART; if (lstrlen(Readers[ii].szDLL)) { lstrcpy(szString, Control.ProgHome); lstrcat(szString, Readers[ii].szDLL); if (!FileExists(szString)) { if ( GetPrivateProfileString( "Micrografx", "Libraries", "", szString, sizeof(STRING), "MGX.INI" ) > 2 ) FixPath( szString ); lstrcat(szString, Readers[ii].szDLL); if (!FileExists(szString)) { ControlEnable( hDlg, i, NO); continue; } } } if (fSaving) ControlEnable( hDlg, i, lpImage && Readers[ii].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))] ); else ControlEnable( hDlg, i, Readers[ii].bOpen ); } if ( bImageOpen && lpImage ) { idDataType = lpImage->DataType; for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i) ControlEnable( hDlg, i, Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]); CheckComboItem( hDlg, IDC_DATATYPES, IDC_SAVECT, IDC_SAVE24BITCOLOR, idDataType ); ControlEnable( hDlg, IDC_SAVECOMPRESS, Readers[idFileType-IDN_ART].bCompressed ); } SetFocus( GetDlgItem( hDlg, IDC_FNAME ) ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL, NULL, MAKELONG(0, 0x7fff)); bNavigated = NO; bDisableCancel = NO; return( FALSE ); case WM_PALETTECHANGED: break; case WM_MENUSELECT: lo = LOWORD(lParam); hi = HIWORD(lParam); if (hi == 0) break; if (lo == -1) break; if (lo & MF_SYSMENU) break; if (lo & MF_POPUP) { hMenu = (HMENU)wParam; while (GetSubMenu(hMenu, 0)) hMenu = GetSubMenu(hMenu, 0); id = GetMenuItemID(hMenu, 0); if (id <= 0) break; wParam = id - 1; } HintLine( wParam ); break; case WM_SETCURSOR: return( SetupCursor( wParam, lParam, idOpen ) ); case WM_CLOSE: AstralDlgEnd( hDlg, FALSE|2 ); break; case WM_MEASUREITEM: case WM_DRAWITEM: id = ((LPDRAWITEMSTRUCT)lParam)->CtlID; Bool = ( id == IDC_DRIVES || id == IDC_DIRS ); return( OwnerDraw( hDlg, msg, lParam, Bool ) ); // break; case WM_CTLCOLOR: return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam), HIWORD(lParam) ) ); case WM_COMMAND: if (wParam != IDCANCEL) bDisableCancel = NO; switch(wParam) { case IDC_FILETYPES: // case IDC_ART: // case IDC_TIFF: // case IDC_BMP: if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) ) break; idFileType = IDN_ART + (wParam-IDC_ART); if (bNavigated) { LookupExtension( idFileType, szFileSpec ); } else GetFileLocation( idFileType, szFileSpec ); for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i) ControlEnable( hDlg, i, Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]); ControlEnable( hDlg, IDC_SAVECOMPRESS, Readers[idFileType-IDN_ART].bCompressed ); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO ); SendMessage( hDlg, WM_COMMAND, IDOK, 0L ); break; case IDC_DATATYPES: // case IDC_SAVECT: // case IDC_SAVELA: // case IDC_SAVESP: // scatterprint // case IDC_SAVE8BITCOLOR: // case IDC_SAVE24BITCOLOR: if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) ) break; idDataType = wParam; break; case IDC_SAVEPATH: Save.OKtoSavePath = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVEPATH, BM_GETCHECK, 0, 0L); // Save.OKtoSavePath = !Save.OKtoSavePath; // CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath ); break; case IDC_SAVECOMPRESS: Save.Compressed = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVECOMPRESS, BM_GETCHECK, 0, 0L); // Save.Compressed = !Save.Compressed; // CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed ); break; case IDC_DRIVES: wMsg = HIWORD(lParam); if ( wMsg != CBN_SELCHANGE ) break; wIndex = SendDlgItemMessage( hDlg, wParam, CB_GETCURSEL, 0, 0L); SendDlgItemMessage( hDlg, wParam, CB_GETLBTEXT, wIndex, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if (CHDRIVE( *szDriveNDir - 'a' )) { LoadComboWithDrives(hDlg, IDC_DRIVES); break; } if (!CURRENTDIR(szString, sizeof(szString))) { GetDlgItemText(hDlg, IDC_FPATH, szString, sizeof(szString)); CHDRIVE(*szString - 'a'); LoadComboWithDrives(hDlg, IDC_DRIVES); } //12/15 SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO); DlgDirList( hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); SetDlgItemText( hDlg, IDC_DISKSPACE, DriveSize( *szDriveNDir - 'a', szString ) ); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); bNavigated = YES; break; case IDC_DIRS: wMsg = HIWORD(lParam); if ( wMsg == LBN_DBLCLK ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != LBN_SELCHANGE ) break; wIndex = SendDlgItemMessage( hDlg, wParam, LB_GETCURSEL, 0, 0L); // Figure out how to build the path name based on the selection SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, wIndex, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if ( id == IDC_PATHICON_OPEN ) i = 0; // Must start building the path from the root else if ( id == IDC_PATHICON_ACTIVE ) i = 9999; // Don't build any path - we're there else i = wIndex; // OK to build a relative path szFileName[0] = '\0'; for ( ; i<=wIndex; i++ ) { SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, i, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if ( id == IDC_PATHICON_CLOSED && i != wIndex ) continue; lstrcat( szFileName, SkipSpaces(szDriveNDir) ); if ( id != IDC_PATHICON_ROOT ) lstrcat( szFileName, "\\" ); } lstrcat( szFileName, szFileSpec ); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); bNavigated = YES; break; case IDC_FLIST: wMsg = HIWORD(lParam); if ( wMsg == LBN_DBLCLK ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != LBN_SELCHANGE ) break; /* If a directory is selected... */ if (DlgDirSelectEx(hDlg, szFileName, sizeof(szFileName), wParam)) lstrcat(szFileName, szFileSpec); // 1-2-92 - TMR - always use SetFileName for all FNAME sets // SetDlgItemText(hDlg, IDC_FNAME, szFileName); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL, NULL, MAKELONG(0, 0x7fff)); // SendDlgItemMessage(hDlg, IDC_FNAME, CB_SETEDITSEL, // NULL, MAKELONG(0, 0x7fff)); break; case IDC_FNAME: /* If the name is changed, disable OK if its length goes 0 */ if (HIWORD(lParam) != EN_CHANGE) // if (HIWORD(lParam) != CBN_EDITCHANGE) break; ControlEnable( hDlg, IDOK, (BOOL)SendDlgItemMessage( hDlg, wParam, WM_GETTEXTLENGTH, 0, 0L)); // 1-2-92 - TMR - make sure Edit Box has focus to make sure // that szSaveName only gets overwritten from user input // 1-3-92 - TMR - move this after ControlEnable if (GetFocus() != GetDlgItem(hDlg, IDC_FNAME)) break; if (fSaving) { GetDlgItemText(hDlg, IDC_FNAME, szSaveName, MAX_FNAME_LEN); fUntitled = NO; } break; case IDC_FPATH: wMsg = HIWORD(lParam); if ( wMsg == BN_DOUBLECLICKED ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != BN_CLICKED ) break; GetDlgItemText(hDlg, wParam, szFileName, sizeof(szFileName)); if ( !szFileName[0] ) break; FixPath( szFileName ); lstrcat( szFileName, szFileSpec ); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); bNavigated = YES; break; case IDOK: GetDlgItemText(hDlg, IDC_FNAME, szFileName,sizeof(szFileName)); bModifySaveName = fSaving && StringsEqual(szFileName, szSaveName); /* Strip off the drive and directory to make */ /* a DlgDirlist() call to switch over to them */ /* Loop backwards over the file name */ l = lstrlen(szFileName); while( --l >= 0 ) { cChar = szFileName[l]; /* If we find a wildcard, the next DlgDirList() takes */ /* care of drive and directory switching; so get out */ if ( cChar == '?' || cChar == '*' ) break; /* If we find a drive or directory, handle it and get out */ if ( cChar == '\\' || cChar == ':' ) { lstrcpy(szDriveNDir, szFileName); l++; szDriveNDir[l] = '\0'; lstrcat(szDriveNDir, szFileSpec); // 1-3-92 - TMR - Handle directory change error if (DlgDirList(hDlg, szDriveNDir, IDC_FLIST, IDC_FPATH, wFileAttr)) lstrcpy( szFileName, &szFileName[l] ); else { szDriveNDir[l] = '\0'; Message(IDS_EDIRECTORYCHANGE, Lowercase(szDriveNDir)); szFileName[0] = '\0'; } break; } } // 1-3-92 - TMR add extension if none present /* Check to see if the file has an extension... */ if ( !lstrchr( szFileName, '.' ) ) // if no extension... if ( LookupExtension( idFileType, szExtension ) ) { if (lstrlen(szFileName)) lstrcat( szFileName, extension(szExtension) ); else lstrcat( szFileName, szExtension); } if (bModifySaveName) lstrcpy(szSaveName, szFileName); /* Try to display a new list box */ if ( !szFileName[0] ) lstrcat(szFileName, szFileSpec); if (DlgDirList(hDlg, szFileName, IDC_FLIST, IDC_FPATH, wFileAttr)) { /* A wildcard was found and a new list displayed */ lstrcpy(szFileSpec, szFileName); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); break; } // If there is still a path or wildcards in the name, the // file specification must be invalid if (lstrchr(szFileName, '\\') || lstrchr(szFileName, ':') || lstrchr(szFileName, '?') || lstrchr(szFileName, '*')) { lstrcpy(szString, szFileName); stripfile(szString); Message(IDS_EDIRECTORYCHANGE, Lowercase(szString)); lstrcpy(szFileSpec, filename(szFileName)); lstrcpy(szFileName, szFileSpec); // is this needed? SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); break; } /* No wildcards, and the drive and dir have been changed */ LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); /* Check to see if the file has 8 characters or less... */ if ( fSaving ) RemoveWhiteSpace( szFileName ); FixFileName( szFileName ); /* Check to see if the file has an extension... */ if ( !lstrchr( szFileName, '.' ) ) // if no extension... if ( LookupExtension( idFileType, szExtension ) ) lstrcat( szFileName, extension(szExtension) ); // Build the fully qualified path name GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) ); FixPath( szString ); lstrcat( szString, szFileName ); /* Check to see if the file exists... */ if ( (fp = _lopen( szString, OF_READ ) ) < 0 ) { /* The file does not exist */ if ( !fSaving ) { Message(IDS_EOPEN, Lowercase(szString)); break; } } else { _lclose( fp ); if ( fSaving ) { if ( !AstralAffirm( IDS_OVERWRITEIMAGE, Lowercase(szString) ) ) break; } } lstrcpy( szFileSpec, szString ); AstralDlgEnd(hDlg, TRUE|2); break; case IDC_CANCEL: case IDCANCEL: if ( bDisableCancel && !LOWORD(lParam) ) break; GetDlgItemText(hDlg, IDC_FPATH, szFileSpec,sizeof(szFileSpec)); AstralDlgEnd(hDlg, FALSE|2); break; default: return( FALSE ); } break; default: return( FALSE ); } return( TRUE ); }
int TiffWriteFrame( int oFile, LPSTR lpFileName, LPOBJECT lpObject, LPFRAME lpFrame, LPRECT lpRect, int flag, BOOL fCompressed, BOOL bEscapable) { TAG tag; int y, bpl, npix, nlin, ofp; LPLONG lngptr,boffptr; LPWORD shtptr; DWORD byteoffset; WORD i, numtags, photomet, samples; BYTE bpp; LPWORD lpRed, lpGreen, lpBlue; RGBS RGBmap[256]; LPTR lp, lpBuffer, lpOutputPointer, lpImgScanline; FNAME temp; RECT rSave; BOOL compressInit; #ifdef STATIC16 // only in new framelib CFrameTypeConvert FrameTypeConvert; FRMTYPEINFO SrcTypeInfo; FRMTYPEINFO DstTypeInfo; #endif lpBuffer = NULL; lpImgScanline = NULL; if (!lpFrame) return( -1 ); ProgressBegin(1,0); if ((ofp = oFile) < 0) bEscapable = !FileExists(lpFileName); if ((ofp = oFile) < 0 && (ofp = _lcreat(lpFileName,0)) < 0) { Message( IDS_EWRITE, lpFileName ); goto Exit; } if (lpRect) rSave = *lpRect; else { rSave.top = rSave.left = 0; rSave.bottom = FrameYSize(lpFrame)-1; rSave.right = FrameXSize(lpFrame)-1; } npix = RectWidth(&rSave); nlin = RectHeight(&rSave); switch(flag) { case IDC_SAVELA : case IDC_SAVESP : bpp = 1; bpl = ((npix + 7) / 8); numtags = 11; photomet = 1; samples = 1; break; case IDC_SAVECT : bpp = 8; bpl = npix; numtags = 11; photomet = 1; samples = 1; break; case IDC_SAVE4BITCOLOR : case IDC_SAVE8BITCOLOR : bpp = 8; bpl = npix; numtags = 12; photomet = 3; samples = 1; break; case IDC_SAVE24BITCOLOR : bpp = 24; bpl = npix * 3; numtags = 11; photomet = 2; samples = 3; break; case IDC_SAVE32BITCOLOR : bpp = 32; bpl = npix * 4; numtags = 11; photomet = 5; samples = 4; break; default : goto Exit; break; } compressInit = NO; if ( bpp == 1 ) { AllocLines( &lpBuffer, 1, npix, 2 ); AllocLines( &lpImgScanline, 1, npix, 1 ); } else { AllocLines( &lpBuffer, 1, max(bpl, FrameByteWidth(lpFrame)), 1 ); AllocLines( &lpImgScanline, 1, max(bpl, FrameByteWidth(lpFrame)), 1 ); } if ( !lpBuffer || !lpImgScanline ) { Message( IDS_EMEMALLOC ); _lclose( ofp ); goto Exit; } /* first location where any extra data can be stored */ /* 10 byte header + all tag data (12 bytes each) + 4 bytes (null ifd) */ byteoffset = 10 + (numtags * sizeof(TAG)) + 4; shtptr = (LPWORD)LineBuffer[0]; SetNextWord(&shtptr, 0x4949); /* byte order is LSB,MSB */ SetNextWord(&shtptr, 0x2a); /* tiff version number */ SetNextWord(&shtptr, 8); /* byte offset to first image file directory LSW */ SetNextWord(&shtptr, 0); /* byte offset to first image file directory MSW */ SetNextWord(&shtptr, numtags); /* number of entries in IFD */ tag.tagno = 0xff; /* tag 0xff, subfile type */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = 1; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x100; /* tag 0x100, number of pixels */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = npix; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x101; /* tag 0x101, number of lines */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = nlin; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x102; /* tag 0x102, bits per sample */ tag.type = 3; /* field type is short */ tag.length = samples; /* number of values */ if ( samples == 3 || samples == 4) { tag.value = byteoffset; /* deferred value */ byteoffset += (samples*sizeof(short)); } else tag.value = bpp; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x103; /* tag 0x103, compression */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = (fCompressed ? 5:1); /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x106; /* tag 0x106,photometric inter.(0 = black) */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = photomet; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x111; /* tag 0x111, strip byte offsets */ tag.type = 4; /* field type is long */ tag.length = 1; /* number of values */ tag.value = 0; /* dummy location of the start of image data */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); boffptr = (LPLONG)(shtptr+4); // make boffptr point at tag.value shtptr += 6; tag.tagno = 0x115; /* tag 0x115, samples per pixel*/ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = samples; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11a; /* tag 0x11a, xresolution */ tag.type = 5; /* field type is rational */ tag.length = 1; /* number of values */ tag.value = byteoffset; /* deferered value */ byteoffset += 8; #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11b; /* tag 0x11b, yresolution */ tag.type = 5; /* field type is rational */ tag.length = 1; /* number of values */ tag.value = byteoffset; /* deferred value */ byteoffset += 8; #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11c; /* tag 0x11c, planar configuration */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = 1; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; if ( photomet == 3 ) // Palette color map { tag.tagno = 0x140; /* tag 0x140, colormap */ tag.type = 3; /* field type is short */ tag.length = 3*256; /* number of values */ tag.value = byteoffset; /* value */ byteoffset += (2*3*256); #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; } // Copy the NULL Image File Directory pointer SetNextWord(&shtptr, 0); /* pointer to next IFD */ SetNextWord(&shtptr, 0); // Copy out the Bits Per Sample, if multiple samples if ( samples == 3 ) // The bits per pixel per sample { SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); } // Copy out the Bits Per Sample, if multiple samples if ( samples == 4 ) // The bits per pixel per sample { SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); } // Copy out the X and Y resolution fields lngptr = (LPLONG)shtptr; #ifdef PPVIDEO SetNextLong(&lngptr, FrameResolution(lpFrame) * 2); /* xreso numerator */ SetNextLong(&lngptr, 2); /* xreso denominator */ SetNextLong(&lngptr, FrameResolution(lpFrame) * 2); /* yreso numerator */ SetNextLong(&lngptr, 2); /* yreso denominator */ #else SetNextLong(&lngptr, FrameResolution(lpFrame)); /* xreso numerator */ SetNextLong(&lngptr, 1); /* xreso denominator */ SetNextLong(&lngptr, FrameResolution(lpFrame)); /* yreso numerator */ SetNextLong(&lngptr, 1); /* yreso denominator */ #endif *boffptr = byteoffset; #ifdef _MAC swapl((LPDWORD)boffptr); #endif // Write out the tags, the bpp, and the resolutions i = (LPTR)lngptr - (LPTR)LineBuffer[0]; if ( _lwrite(ofp, LineBuffer[0], i) != i ) goto BadWrite; // Write the color palette, if necessary if ( photomet == 3 ) // Palette color map { if (!OptimizeBegin(lpObject, lpFrame, RGBmap, 256, NULL /*(LPROC)AstralClockCursor*/, // No Progress report NO, Convert.fOptimize, Convert.fScatter, Convert.fDither, npix)) goto BadWrite; lpRed = (LPWORD)LineBuffer[0]; lpGreen = lpRed + 256; lpBlue = lpGreen + 256; for ( i=0; i<256; i++ ) { *lpRed++ = (WORD)RGBmap[i].red << 8; *lpGreen++ = (WORD)RGBmap[i].green << 8; *lpBlue++ = (WORD)RGBmap[i].blue << 8; } if ( _lwrite(ofp, LineBuffer[0], 2*3*256) != 2*3*256 ) goto BadWrite; } if ( fCompressed ) { if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Initialize */ goto BadWrite; compressInit = YES; } switch(bpp) { case 1 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameDepth(lpFrame) == 0) { if (flag == IDC_SAVESP) diffuse( 0, i, 0, NULL, lp, npix, lpBuffer ); else con2la( lp, npix, lpBuffer ); } else { ConvertData( lp, FrameDepth(lpFrame), npix, lpBuffer+npix, 1 ); if ( flag == IDC_SAVESP ) diffuse( 0, i, 0, NULL, lpBuffer+npix, npix, lpBuffer ); else con2la( lpBuffer+npix, npix, lpBuffer ); } if ( fCompressed ) { if ( CompressLZW( ofp, lpBuffer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpBuffer, bpl ) != bpl ) goto BadWrite; } } break; case 8 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameDepth(lpFrame) == 0) { if ( photomet == 3 ) // If we are storing palette color OptimizeData(0, y, npix, lp, lpBuffer, 1 ); else ConvertData( lp, 1, npix, lpBuffer, 1 ); } else { if ( photomet == 3 ) // If we are storing palette color OptimizeData(0, y, npix, lp, lpBuffer, FrameDepth(lpFrame)); else ConvertData( lp, FrameDepth(lpFrame), npix, lpBuffer, 1 ); } if ( fCompressed ) { if ( CompressLZW( ofp, lpBuffer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpBuffer, bpl ) != bpl ) goto BadWrite; } } break; case 24 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameType(lpFrame) != FDT_RGBCOLOR) { if (FrameType(lpFrame) != FDT_LINEART) { #ifdef STATIC16 SrcTypeInfo.DataType = FrameType(lpFrame); SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_RGBCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FrameType(lpFrame), NULL, y, (LPTR)lpBuffer, FDT_RGBCOLOR, NULL, npix); #endif } else { #ifdef STATIC16 SrcTypeInfo.DataType = FDT_GRAYSCALE; SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_RGBCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FDT_GRAYSCALE, NULL, y, (LPTR)lpBuffer, FDT_RGBCOLOR, NULL, npix); #endif } lpOutputPointer = lpBuffer; } else { lpOutputPointer = lp; } if ( fCompressed ) { if ( CompressLZW( ofp, lpOutputPointer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpOutputPointer, bpl ) != bpl ) goto BadWrite; } } break; case 32 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameType(lpFrame) != FDT_CMYKCOLOR) { if (FrameType(lpFrame) != FDT_LINEART) { #ifdef STATIC16 SrcTypeInfo.DataType = FrameType(lpFrame); SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_CMYKCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FrameType(lpFrame), NULL, y, (LPTR)lpBuffer, FDT_CMYKCOLOR, NULL, npix); #endif } else { #ifdef STATIC16 SrcTypeInfo.DataType = FDT_GRAYSCALE; SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_CMYKCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FDT_GRAYSCALE, NULL, y, (LPTR)lpBuffer, FDT_CMYKCOLOR, NULL, npix); #endif } lpOutputPointer = lpBuffer; } else { lpOutputPointer = lp; } if ( fCompressed ) { if ( CompressLZW( ofp, lpOutputPointer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpOutputPointer, bpl ) != bpl ) goto BadWrite; } } break; } if ( compressInit ) if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Terminate */ goto BadWrite; compressInit = NO; OptimizeEnd(); if (ofp != oFile) _lclose(ofp); if (lpBuffer) FreeUp( lpBuffer ); if (lpImgScanline) FreeUp( lpImgScanline ); ProgressEnd(); return( 0 ); BadWrite: Message( IDS_EWRITE, lpFileName ); goto BadTiff; BadRead: Message( IDS_EREAD, (LPTR)Control.RamDisk ); Cancelled: BadTiff: if ( compressInit ) if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Terminate */ goto BadWrite; compressInit = NO; OptimizeEnd(); if (ofp != oFile) _lclose(ofp); lstrcpy(temp,lpFileName); FileDelete(temp); Exit: if (lpBuffer) FreeUp( lpBuffer ); if (lpImgScanline) FreeUp( lpImgScanline ); ProgressEnd(); return( -1 ); }
BOOL PSPrint( LPIMAGE lpImage, LPFRAME lpFrame, BYTE cSep, int xSrc, int ySrc, int dxSrc, int dySrc, int xDest, int yDest, int dxDest, int dyDest, int iPrResX, int iPrResY ) { int y, yline, ystart, ylast, x, depth; LFIXED yrate, yoffset; LPTR lpBuffer[5], p1Buf, p2Buf, p3Buf, p4Buf; LPSTR lpAngle, lpRuling; LPTR lpImageData; BOOL Negative, Asciize; STRING szAngle, szRuling; long lSize; LPFRAME lpBaseFrame; #define C_ANGLE Halftone.ScreenAngle[0] #define M_ANGLE Halftone.ScreenAngle[1] #define Y_ANGLE Halftone.ScreenAngle[2] #define K_ANGLE Halftone.ScreenAngle[3] #define C_RULING Halftone.ScreenRuling[0] #define M_RULING Halftone.ScreenRuling[1] #define Y_RULING Halftone.ScreenRuling[2] #define K_RULING Halftone.ScreenRuling[3] ProgressBegin(1,0); lpAngle = szAngle; lpRuling = szRuling; Negative = Page.Negative; Asciize = !Page.BinaryPS; PS_ID( IDS_PS_DICTDEF ); /* Send the definition of the read data function */ if ( Asciize ) { PS_ID( IDS_PS_HEXDATA ); } else { PS_ID( IDS_PS_BINDATA ); } if ( !Halftone.DoHalftoning ) goto HalftoningDone; /* Send the definition of the spot function */ if ( Halftone.DotShape == IDC_ELLIPSEDOT ) { PS_ID( IDS_PS_ELLDOT1 ); PS_ID( IDS_PS_ELLDOT2 ); } else if ( Halftone.DotShape == IDC_SQUAREDOT ) { PS_ID( IDS_PS_SQUDOT ); } else if ( Halftone.DotShape == IDC_CIRCLEDOT ) { PS_ID( IDS_PS_CIRDOT ); } else if ( Halftone.DotShape == IDC_TRIANGLEDOT ) { PS_ID( IDS_PS_TRIDOT ); } else if ( Halftone.DotShape == IDC_PROPELLERDOT ) { PS_ID( IDS_PS_PROPDOT ); } if ( Page.OutputType == IDC_PRINT_BLACKSEPS || Page.OutputType == IDC_PRINT_GRAY ) { // Setup the "image" screen angles and freqs based on the sep if ( cSep == 'C' ) { FixedAscii( C_ANGLE, lpAngle, -2 ); FixedAscii( C_RULING, lpRuling, -2 ); } else if ( cSep == 'M' ) { FixedAscii( M_ANGLE, lpAngle, -2 ); FixedAscii( M_RULING, lpRuling, -2 ); } else if ( cSep == 'Y' ) { FixedAscii( Y_ANGLE, lpAngle, -2 ); FixedAscii( Y_RULING, lpRuling, -2 ); } else //if ( cSep == 'K' || cSep == 'X' || !cSep ) { FixedAscii( K_ANGLE, lpAngle, -2 ); FixedAscii( K_RULING, lpRuling, -2 ); } PS_ID2( IDS_PS_SETSCREEN, lpRuling, lpAngle ); } else { // Setup the "colorimage" screen angles and frequencies PS_ID( IDS_PS_COLOREXT ); PS_ID( IDS_PS_STARTBLOCK ); FixedAscii( C_RULING, lpRuling, -2 ); FixedAscii( C_ANGLE, lpAngle, -2 ); PS_ID2( IDS_PS_SETSPOT, lpRuling, lpAngle ); FixedAscii( M_RULING, lpRuling, -2 ); FixedAscii( M_ANGLE, lpAngle, -2 ); PS_ID2( IDS_PS_SETSPOT, lpRuling, lpAngle ); FixedAscii( Y_RULING, lpRuling, -2 ); FixedAscii( Y_ANGLE, lpAngle, -2 ); PS_ID2( IDS_PS_SETSPOT, lpRuling, lpAngle ); FixedAscii( K_RULING, lpRuling, -2 ); FixedAscii( K_ANGLE, lpAngle, -2 ); PS_ID2( IDS_PS_SETSPOT, lpRuling, lpAngle ); PS_ID( IDS_PS_SETCOLORSCREEN ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); FixedAscii( K_RULING, lpRuling, -2 ); FixedAscii( K_ANGLE, lpAngle, -2 ); PS_ID2( IDS_PS_SETSCREEN, lpRuling, lpAngle ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IFELSE ); } HalftoningDone: // Setup a null transfer curve unless doing seps w/black ink (image operator) if ( Page.OutputType == IDC_PRINT_BLACKSEPS ) { PS_ID( IDS_PS_BLACKSEPS ); } else if ( Page.OutputType == IDC_PRINT_COLORSEPS ) { PS_ID( IDS_PS_COLORSEPS ); } else { PS_ID( IDS_PS_NOINVERT ); } PS_ID( IDS_PS_CHECKINVERT ); /* Send the destination point (x,y) in spots */ PS_ID2( IDS_PS_TRANSLATE, xDest, yDest ); /* Send the destination size (w,h) in spots */ PS_ID2( IDS_PS_SCALE, dxDest, dyDest ); if (lpImage) lpBaseFrame = ImgGetBaseEditFrame(lpImage); else lpBaseFrame = lpFrame; /* Compute how many pixels we're going to send */ /* Never send more than 16 pixels per halftone grid (or 4/grid in x and y) */ if (depth = FrameDepth( lpBaseFrame )) { if ( iPrResX < 600 ) dxDest /= 4; else dxDest /= 8; if ( iPrResY < 600 ) dyDest /= 4; else dyDest /= 8; } if (depth == 0) depth = 1; /* Let the printer do any upsizing */ if ( dySrc < dyDest ) { yrate = UNITY; dxDest = dxSrc; dyDest = dySrc; } else yrate = FGET( dySrc, dyDest ); /* Send the definition for the line buffers */ PS_ID1( IDS_PS_LINE1, dxDest ); PS_ID1( IDS_PS_LINE2, dxDest ); PS_ID1( IDS_PS_LINE3, dxDest ); PS_ID1( IDS_PS_LINE4, dxDest ); PS_ID1( IDS_PS_LINE5, dxDest ); if ( cSep ) // Plane at a time { // cSep is either 'C', 'M', 'Y', 'K', 'X'(gray) or NULL if ( Page.OutputType == IDC_PRINT_COLORSEPS ) { PS_ID( IDS_PS_DOCOLORSEPDEF ); } else { PS_ID( IDS_PS_NOCOLORSEPDEF ); } PS_ID( IDS_PS_DOIMAGEDEF ); PS_ID( IDS_PS_COLORSEPVAL ); // Start color image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); if ( cSep == 'C' ) { PS_ID( IDS_PS_SEPCYAN ); } else if ( cSep == 'M' ) { PS_ID( IDS_PS_SEPMAGENTA ); } else if ( cSep == 'Y' ) { PS_ID( IDS_PS_SEPYELLOW ); } else if ( cSep == 'K' || cSep == 'X' ) { PS_ID( IDS_PS_SEPBLACK ); } PS_ID( IDS_PS_COLORIMAGE4 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); // Start gray image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_GETLINE1 ); PS_ID( IDS_PS_IMAGE ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IFELSE ); PS_ID( IDS_PS_DEF ); } else if ( Page.Type == IDC_PRINTER_IS_CMYK ) { if (Page.OutputType == IDC_PRINT_COLORGRAY) { PS_ID( IDS_PS_DOIMAGEDEF ); PS_ID( IDS_PS_COLOREXT ); // Start color image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_GETLINE1 ); PS_ID( IDS_PS_GETLINE2 ); PS_ID( IDS_PS_GETLINE3 ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_GETLINE4 ); PS_ID( IDS_PS_GETLINE5 ); PS_ID( IDS_PS_POP ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_COLORIMAGE4 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); // Start gray image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_DUMPLINE1 ); PS_ID( IDS_PS_DUMPLINE2 ); PS_ID( IDS_PS_DUMPLINE3 ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_GETLINE4 ); PS_ID( IDS_PS_GETLINE5 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IMAGE ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IFELSE ); PS_ID( IDS_PS_DEF ); } else { PS_ID( IDS_PS_DOIMAGEDEF ); PS_ID( IDS_PS_COLOREXT ); // Start color image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_GETLINE1 ); PS_ID( IDS_PS_GETLINE2 ); PS_ID( IDS_PS_GETLINE3 ); PS_ID( IDS_PS_GETLINE4 ); PS_ID( IDS_PS_COLORIMAGE4 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); // Start gray image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_DUMPLINE1 ); PS_ID( IDS_PS_DUMPLINE2 ); PS_ID( IDS_PS_DUMPLINE3 ); PS_ID( IDS_PS_GETLINE4 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_NOIMAGE ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IFELSE ); PS_ID( IDS_PS_DEF ); } } else if ( Page.Type == IDC_PRINTER_IS_RGB ) { PS_ID( IDS_PS_DOIMAGEDEF ); PS_ID( IDS_PS_COLOREXT ); // Start color image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_GETLINE1 ); PS_ID( IDS_PS_GETLINE2 ); PS_ID( IDS_PS_GETLINE3 ); if ( Page.OutputType == IDC_PRINT_COLORGRAY ) { PS_ID( IDS_PS_DUMPLINE4 ); } PS_ID( IDS_PS_COLORIMAGE3 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); // Start gray image proc PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_STARTBLOCK ); PS_ID( IDS_PS_DUMPLINE1 ); PS_ID( IDS_PS_DUMPLINE2 ); if ( Page.OutputType == IDC_PRINT_COLORGRAY ) { PS_ID( IDS_PS_DUMPLINE3 ); PS_ID( IDS_PS_GETLINE4 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IMAGE ); } else { PS_ID( IDS_PS_GETLINE3 ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_NOIMAGE ); } PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_ENDBLOCK ); PS_ID( IDS_PS_IFELSE ); PS_ID( IDS_PS_DEF ); } /* Send the inline image's size, packing, and transform */ PS_ID5( IDS_PS_TRANSFORM, dxDest, dyDest, 8, dxDest, dyDest ); if ( !Asciize ) { // The size must include the doimage command that follows lSize = (long)dxDest * dyDest * depth; PS_ID1( IDS_PS_BEGINBINARY, lSize + 9 + 2 ); } PS_ID( IDS_PS_DOIMAGE ); // Should be 9 characters for ( x=0; x<5; x++ ) lpBuffer[x] = NULL; if (!AllocLines((LPPTR)&lpImageData, 1, dxSrc, depth)) { ProgressEnd(); return(FALSE); } if (!AllocLines((LPPTR)&lpBuffer[0], 1, dxDest, depth)) { FreeUp( lpImageData ); ProgressEnd(); return( FALSE ); } if (!AllocLines((LPPTR)&lpBuffer[1], 4, dxDest, 1)) { FreeUp(lpBuffer[0]); FreeUp( lpImageData ); ProgressEnd(); return( FALSE ); } p1Buf = lpBuffer[1]; p2Buf = lpBuffer[2]; p3Buf = lpBuffer[3]; p4Buf = lpBuffer[4]; ystart = ySrc; yline = -1; yoffset = (long)yrate>>1; for (y=0; y<dyDest; y++) { if (AstralClockCursor( y, dyDest, YES )) { fAbortPrint = YES; break; } /* Check for user input to abort dialog box */ (*lpAbortTest)(hPrinterDC, 0); if ( fAbortPrint ) break; ylast = yline; #ifdef WIN32 yline = ystart + WHOLE( yoffset ); #else yline = ystart + HIWORD( yoffset ); #endif yoffset += yrate; if ( yline != ylast ) { LFIXED rate; if (lpImage) ImgGetLine( lpImage, NULL, xSrc, yline, dxSrc, lpImageData ); else copy(FramePointer(lpBaseFrame, xSrc, yline, NO), lpImageData, dxSrc*depth); rate = FGET( dxSrc, dxDest ); FrameSample( lpBaseFrame, lpImageData, 0, lpBuffer[0], 0, dxDest, rate); } if ( cSep ) { // cSep is either 'C', 'M', 'Y', 'K', 'X'(gray) or NULL if (cSep != 'X') { LPTR lpOutBuf; int iPlaneOffset; switch(cSep) { case 'C' : lpOutBuf = p1Buf; iPlaneOffset = 0; break; case 'M' : lpOutBuf = p2Buf; iPlaneOffset = 1; break; case 'Y' : lpOutBuf = p3Buf; iPlaneOffset = 2; break; case 'K' : lpOutBuf = p4Buf; iPlaneOffset = 3; break; } switch(depth) { case 0 : case 1 : lpOutBuf = (LPTR)lpBuffer[0]; break; case 3 : ClrRGBtoCMYK( (LPRGB)lpBuffer[0], p1Buf, p2Buf, p3Buf,p4Buf,dxDest,YES); break; case 4 : { LPTR lpSrc = (LPTR)lpBuffer[0]; LPTR lpDst = lpOutBuf; int iCount = dxDest; lpSrc += iPlaneOffset; while(iCount-- > 0) { *lpDst++ = *lpSrc; lpSrc += 4; } } break; } if (Negative) negate(lpOutBuf, (long)dxDest); if ( !SendPSData( Asciize, lpOutBuf, dxDest ) ) goto ErrorExit; } else { ConvertData( lpBuffer[0], depth, dxDest, p1Buf, 1 ); if (Negative) negate(p1Buf, (long)dxDest); CorrectGray( p1Buf, dxDest, YES, YES ); if ( !SendPSData( Asciize, p1Buf, dxDest ) ) goto ErrorExit; } } else if ( Page.Type == IDC_PRINTER_IS_CMYK ) { switch(depth) { case 0 : case 1 : copy( lpBuffer[0], p1Buf, dxDest ); copy( lpBuffer[0], p2Buf, dxDest ); copy( lpBuffer[0], p3Buf, dxDest ); copy( lpBuffer[0], p4Buf, dxDest ); break; case 3 : ClrRGBtoCMYK( (LPRGB)lpBuffer[0], p1Buf, p2Buf, p3Buf,p4Buf,dxDest,YES); break; case 4 : { LPTR lpSrc = (LPTR)lpBuffer[0]; LPTR lpDst1 = p1Buf; LPTR lpDst2 = p2Buf; LPTR lpDst3 = p3Buf; LPTR lpDst4 = p4Buf; int iCount = dxDest; while(iCount-- > 0) { *lpDst1++ = *lpSrc++; *lpDst2++ = *lpSrc++; *lpDst3++ = *lpSrc++; *lpDst4++ = *lpSrc++; } } break; } if (Negative) { negate(p1Buf, (long)dxDest); negate(p2Buf, (long)dxDest); negate(p3Buf, (long)dxDest); negate(p4Buf, (long)dxDest); } if ( !SendPSData( Asciize, p1Buf, dxDest ) ) goto ErrorExit; if ( !SendPSData( Asciize, p2Buf, dxDest ) ) goto ErrorExit; if ( !SendPSData( Asciize, p3Buf, dxDest ) ) goto ErrorExit; if ( !SendPSData( Asciize, p4Buf, dxDest ) ) goto ErrorExit; if ( Page.OutputType == IDC_PRINT_COLORGRAY ) { ConvertData( lpBuffer[0], depth, dxDest, p1Buf, 1 ); if (Negative) negate(p1Buf, (long)dxDest); CorrectGray( p1Buf, dxDest, YES, YES); if ( !SendPSData( Asciize, p1Buf, dxDest ) ) goto ErrorExit; } } else if ( Page.Type == IDC_PRINTER_IS_RGB ) { switch(depth) { case 0 : case 1 : copy( lpBuffer[0], p1Buf, dxDest ); copy( lpBuffer[0], p2Buf, dxDest ); copy( lpBuffer[0], p3Buf, dxDest ); break; case 3 : UnshuffleRGB( (LPRGB)lpBuffer[0], p1Buf, p2Buf, p3Buf, dxDest ); break; case 4 : { LPCMYK lpCMYK = (LPCMYK)lpBuffer[0]; LPTR lpDst1 = p1Buf; LPTR lpDst2 = p2Buf; LPTR lpDst3 = p3Buf; RGBS rgb; int iCount = dxDest; while(iCount-- > 0) { CMYKtoRGB(lpCMYK->c, lpCMYK->m, lpCMYK->y, lpCMYK->k, &rgb); lpCMYK++; *lpDst1++ = rgb.red; *lpDst2++ = rgb.green; *lpDst3++ = rgb.blue; } } break; } if (Negative) { negate( p1Buf, dxDest ); negate( p2Buf, dxDest ); negate( p3Buf, dxDest ); } if ( !SendPSData( Asciize, p1Buf, dxDest ) ) goto ErrorExit; if ( !SendPSData( Asciize, p2Buf, dxDest ) ) goto ErrorExit; if ( !SendPSData( Asciize, p3Buf, dxDest ) ) goto ErrorExit; if ( Page.OutputType == IDC_PRINT_COLORGRAY ) { ConvertData( (LPTR)lpBuffer[0], depth, dxDest, p1Buf, 1 ); if (Negative) negate(p1Buf, (long)dxDest); CorrectGray( p1Buf, dxDest, YES, YES); if ( !SendPSData( Asciize, p1Buf, dxDest ) ) goto ErrorExit; } } } if ( !Asciize ) { PS_ID( IDS_PS_ENDBINARY ); } /* Send the save restore command */ PS_ID( IDS_PS_MYSAVERESTORE ); PS_ID( IDS_PS_END ); ErrorExit: if ( lpBuffer[0] ) FreeUp(lpBuffer[0]); if ( lpBuffer[1] ) FreeUp(lpBuffer[1]); if ( lpImageData ) FreeUp( lpImageData ); ProgressEnd(); return( TRUE ); }