示例#1
0
void FloodProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
FRMDATATYPE type;
int res;
FLOOD_PARMS parms;
LPIMAGE lpImage;
RECT rArea;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!IsOnImage(hWindow, x, y))
		break;
	Display2File(hWindow,&x, &y);
	lpImage = (LPIMAGE)GetImagePtr(hWindow);
	type = FrameType(ImgGetBaseEditFrame(lpImage));
	res = FrameResolution(ImgGetBaseEditFrame(lpImage));
	parms.FloodOpacity = Fill.FloodOpacity;
	parms.FloodMergeMode = Fill.FloodMergeMode;
	GetActiveColorFromType(type, &parms.Color);
	parms.iBaseRes = res;
	parms.x = x;
	parms.y = y;
	rArea.left = rArea.right = x;
	rArea.top = rArea.bottom = y;
	Measure(lpImage, &rArea, &parms.InColor);
	parms.FloodRange = Fill.FloodRange;
	parms.FloodFade = Fill.FloodFade;
	parms.idFloodColorModel = Fill.idFillColorModel;
	ProcessCommand(lpImage->lpCmdList, IDS_CMD_FLOOD, &parms);
	break;

    case WM_LBUTTONDOWN:
	break;

    case WM_LBUTTONUP:
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	Tool.bActive = NO;
	break;
    }
}
示例#2
0
void InitSpin( HWND hDlg, LFIXED fSetX, LFIXED fSetY, int flag)
/************************************************************************/
{
LPIMAGE	lpImage;
LPFRAME	lpFrame;
LFIXED	fMin, fMax;
RECT		iRect;
int 		res;

if( !( lpImage = GetActiveImage() ) )
	return;
lpFrame = ImgGetBaseEditFrame( lpImage );

ImgGetImageRect( lpImage, &iRect );

res = FrameResolution( lpFrame );

if (flag & 1)
   {
   fMax = FGET( iRect.right, res );
   fMin = FGET( -iRect.right, res );
   InitDlgItemSpinFixed( hDlg, IDC_POS_X, fSetX, YES, fMin, fMax );
   }

if (flag & 2)
   {
   fMax = FGET( iRect.bottom, res );
   fMin = FGET( -iRect.bottom, res );
   InitDlgItemSpinFixed( hDlg, IDC_POS_Y, fSetY, YES, fMin, fMax );
   }
SetUnitLabels(hDlg);
}
示例#3
0
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();

}
示例#4
0
void View1TO1()
   {
   int x, y, res, ratio;
   LFIXED fixed;
   HDC hDC;
   HWND hWnd;
   LPDISPLAY lpDisplay;
   LPIMAGE lpImage;

	if (hWnd = GetActiveDoc())
      {
	   lpImage = GetImagePtr(hWnd);
	   lpDisplay = GetDisplayPtr(hWnd);
	   hDC = GetDC( PictPubApp.Get_hWndAstral() );
	   x = GetDeviceCaps( hDC, HORZRES ); // in pixels
	   ReleaseDC( PictPubApp.Get_hWndAstral(), hDC );
	   fixed = FGET( FUNITY, Control.ScreenWidth );
	   if (res = FMUL( x, fixed)) // in pixels/inch
         {
	      ratio = ( 100L * res ) / FrameResolution(ImgGetBaseEditFrame(lpImage));
	      x = ( lpDisplay->FileRect.left 
		   + lpDisplay->FileRect.right ) / 2;
	      y = ( lpDisplay->FileRect.top 
		   + lpDisplay->FileRect.bottom ) / 2;
	      Zoom( hWnd, x, y, ratio, NO, View.ZoomWindow );
         }
      }
   }
示例#5
0
void StatusOfRectangle(
/***********************************************************************/
LPRECT lpRect,
LFIXED fScale)
{
STRING szUnit, szString1, szString2, szString3, szString4;
LPSTR lpUnit;
RECT rFile;
int Resolution;

OrderRect( lpRect, &rFile );
if ( fScale )
	{
	Resolution = 1000;
	ScaleRect( &rFile, fScale );
	}
else
if (lpImage)
	Resolution = FrameResolution( ImgGetBaseEditFrame(lpImage) );
if ( AstralStr( Control.Units-IDC_PREF_UNITINCHES+IDS_INCHES, &lpUnit ) )
	{
	lstrcpy( szUnit, lpUnit );
	MessageStatus( IDS_RECT_STATUS,
		Unit2String( FGET( RectWidth(&rFile), Resolution ), szString1 ),
		Unit2String( FGET( RectHeight(&rFile), Resolution ), szString2),
		(LPSTR)szUnit,
		Unit2String( FGET( rFile.left, Resolution ), szString3 ),
		Unit2String( FGET( rFile.top, Resolution ), szString4 ) );
	}
}
示例#6
0
BOOL CHistogramDlg::OnInitDialog()
{
	HWND hActiveWnd;
	HWND hTags;
	FRMDATATYPE type;
	LPIMAGE lpImage = NULL;
	int icons[HISTOMARKS];
	HWND hDlg = GetSafeHwnd();
	

	lpImage = GetImage();
	RightPopup( hDlg );
	
	// set channels combo
	type = FrameType(ImgGetBaseEditFrame(lpImage));
	m_wChannel = IDC_DO_ALL;
	m_MapValues.wChannel = m_wChannel;
	ChannelsCombo_Setup(IDC_CHANNELS, type);	 //This NEEDS to be fixed!!!

	
	// setup tags
	hTags = ::GetDlgItem(hDlg, IDC_TAGS);
	icons[0] = IDC_HISTOTAG1;
	icons[1] = IDC_HISTOTAG2;
	Tag_Init(hTags, HISTOMARKS, 255, &icons[0]);
	Tag_SetMark(hTags, 0, 85, NO);
	Tag_SetMark(hTags, 1, 170, NO);
	
	m_lpHistos[0] = NULL;
	
	// setup the actual histogram and controls 
	set_histo_channel();
	return CPPMapExDlg::OnInitDialog();
}
示例#7
0
LOCAL BOOL Pos_OnInitDialog(HWND hDlg, HWND hWndFocus, LPARAM lParam)
/************************************************************************/
{
RECT     rSel;
LPIMAGE  lpImage;
LPFRAME	lpFrame;
LFIXED   XPos, YPos;
int 		res;

if(!(lpImage = GetActiveImage()))
	return(FALSE);

lpFrame = ImgGetBaseEditFrame( lpImage );
res = FrameResolution( lpFrame );
ImgGetSelObjectRect(lpImage, &rSel, YES);
XPos = FGET(rSel.left, res); 
YPos = FGET(rSel.top, res); 

CheckComboItem( hDlg, IDC_PREF_UNITS, IDC_PREF_UNITINCHES,
	IDC_PREF_UNITPIXELS,	IDC_PREF_UNITINCHES );

lpPosParms = (LPPOSOBJECTS_PARMS)lParam;

Edit.SaveUnits = Control.Units;

SetUnitResolution( 0 );

InitSpin( hDlg, XPos, YPos,3);

CenterPopup( hDlg );
return(TRUE);
}
示例#8
0
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();
}
示例#9
0
void ResizePuzzleFrame(LPFRAME lpNewFrame)
{
    LPFRAME     lpOldFrame;
    LPFRAME     lpPrevFrame;
    double      fXMult;
    double      fYMult;
    double      fMult;
    int         iXNew;
    int         iYNew;
    int         iXOld;
    int         iYOld;

    lpOldFrame = ImgGetBaseEditFrame(lpImage);
    iXNew = FrameXSize(lpNewFrame);
    iYNew = FrameYSize(lpNewFrame);
    iXOld = FrameXSize(lpOldFrame);
    iYOld = FrameYSize(lpOldFrame);

    fXMult = (double)iXOld / (double)iXNew;
    fYMult = (double)iYOld / (double)iYNew;
        
    if (fXMult < fYMult)
         fMult = fXMult;
    else fMult = fYMult;
    iXNew = (int)((double)iXNew * fMult);
    iYNew = (int)((double)iYNew * fMult);
    
    lpPrevFrame = lpNewFrame;
    lpNewFrame = SizeFrame(
        lpNewFrame, 
        iXNew, 
        iYNew, 
        FrameResolution(lpOldFrame),
		FALSE);
    FrameClose(lpPrevFrame);

    iXNew = (FrameXSize(lpOldFrame) - FrameXSize(lpNewFrame)) / 2;
    iYNew = (FrameYSize(lpOldFrame) - FrameYSize(lpNewFrame)) / 2;
    iXNew = max(0, iXNew);
    iYNew = max(0, iYNew);
    lpPrevFrame = lpNewFrame;
    lpNewFrame = ExpandFrame(lpNewFrame, 
                    FrameXSize(lpOldFrame), /*pix*/ 
                    FrameYSize(lpOldFrame), /*lin*/ 
                    iXNew,                  /*left*/ 
                    iYNew,                  /*top*/ 
					FrameGetBackground(lpOldFrame));

    ImgReplaceBaseEditFrame(lpImage, lpNewFrame);
    FrameClose(lpPrevFrame);
}
示例#10
0
void RemoveCodedBackground()
{
    LPFRAME lpFrame;
    int x, y;
    int Width;
    int Height;
    LPTR lpSrcLine;
    BYTE r, g, b;
    
    if (!lpImage) return;
    ImgCombineObjects(lpImage, TRUE, FALSE, TRUE);
    lpFrame = ImgGetBaseEditFrame(lpImage);
    if (!lpFrame) return;
    Width  = FrameXSize (lpFrame);
    Height = FrameYSize (lpFrame);

    for (y=0;y<Height;y++)
    {
	    AstralClockCursor( y, Height, NO );
        lpSrcLine = FramePointer (lpFrame,0,y,TRUE);

        for (x=0;x<Width;x++)
        {
            RGBS Pixel;
            FrameGetRGB (lpFrame,lpSrcLine,&Pixel,1);
            r = Pixel.red;
            g = Pixel.green;
            b = Pixel.blue;

            if (r >= 100 && !g && !b)
            { // a dot
                Pixel.red   = 255;
                Pixel.green = 255;
                Pixel.blue  = 255;
                FrameSetRGB (lpFrame,&Pixel,lpSrcLine,1);
            }
			else
            if ( (r != g) || (g != b) )
            { // not white or black
                Pixel.red   = 0;
                Pixel.green = 0;
                Pixel.blue  = 0;
                FrameSetRGB (lpFrame,&Pixel,lpSrcLine,1);
            }
            lpSrcLine += 3;
            
        } // Width
    }     // Height
}
示例#11
0
int CSizeImageDlg::SetUnitResolution( int res )
{
	int OldUnitRes;
	LPIMAGE lpImage = GetImage();

	OldUnitRes = m_UnitRes;

	if ( !(m_UnitRes = res) )
	{
		m_UnitRes =
			( lpImage ? FrameResolution(ImgGetBaseEditFrame(lpImage)) : 1000 );
	}
	// setup control library
	SetUnitInfo((UNIT_TYPE)(m_Units-IDC_PREF_UNITINCHES), m_UnitRes, m_Points);

	return( OldUnitRes );
}
示例#12
0
CToneBalanceDlg::OnInitDialog()
{
	HWND hControl;
	FRMDATATYPE type;
	LPIMAGE lpImage = NULL;
	int i;
	LONG style;
	HWND hDlg = GetSafeHwnd();
	PreDoModal();	
	m_lpData = (LPQUARTERSTRUCT)Alloc(sizeof(QUARTERSTRUCT));
	if (!m_lpData)
		return(FALSE);
	for (i=0;i<3;i++) 	// setup tag sliders
	{
		if (hControl = ::GetDlgItem(hDlg, i+IDC_QUART1))
		{
			style = GetWindowLong(hControl, GWL_EXSTYLE);
			style |= WS_EX_TRANSPARENT;
			SetWindowLong(hControl, GWL_EXSTYLE, style);
		}
	}

	lpImage = GetImage();
	RightPopup( hDlg );
	
	// set channels combo
	type = FrameType(ImgGetBaseEditFrame(lpImage));
	m_lpData->wChannel = IDC_DO_ALL;
	m_MapValues.wChannel = m_lpData->wChannel; //this is not a very good	solution
	ChannelsCombo_Setup(IDC_CHANNELS, type);

	ControlEnable(hDlg, IDC_PREVIEW, !m_bAutoPreview);

	// remove or add percents
	SetAllDlgItemsText(hDlg, IDC_PERCENT, m_bPercentages ? (LPSTR)"%":(LPSTR)"");
	
	m_lpData->lpHistos[0] = NULL;
	ResetAllMaps();
	
	// setup each channel with defaults
	for (i=IDC_DO_ALL; i<=IDC_DO_BLACK;i++)
		reset_channel(i);
	// setup the actual histogram and controls 
	set_quarter_channel(m_lpData->wChannel);
	return CPPMapDlg::OnInitDialog();
}
示例#13
0
void TintFillProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
LPIMAGE lpImage;
FRMDATATYPE type;
TINTFILL_PARMS parms;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!IsOnImage(hWindow, x, y))
		break;
    lpImage = (LPIMAGE)GetImagePtr ( hWindow );
	type = FrameType(ImgGetBaseEditFrame(lpImage));

	parms.FillOpacity = Fill.FillOpacity;
	parms.FillMergeMode = Fill.FillMergeMode;
	GetActiveColorFromType(type, &parms.Color);

	ProcessCommand(lpImage->lpCmdList, IDS_CMD_TINTFILL, &parms);
	break;

    case WM_LBUTTONDOWN:
	break;

    case WM_LBUTTONUP:
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	Tool.bActive = NO;
	break;
    }
}
示例#14
0
static BOOL NEAR PathIsClear (int x1,int y1,int x2,int y2)
{
    BOOL bClear = TRUE;
    int  i;
    LPFRAME lpFrame = ImgGetBaseEditFrame (lpImage);

    nNumLinePoints = 0;
    ddaline (x1,y1,x2,y2, (LPPOINTFUNC)MazeLineProc);
    for (i = 0; i < nNumLinePoints; i++)
    {
        RGBS Pixel;
        LPTR lpLine = FramePointer (lpFrame,
            MazeLinePoints[i].x,MazeLinePoints[i].y,FALSE);

        FrameGetRGB (lpFrame,lpLine,&Pixel,1);
        if (!Pixel.red && !Pixel.green && !Pixel.blue)
        {
            bClear = FALSE;
            break;
        }
    }
    return bClear;
}
示例#15
0
void InitPoints()
{
	int 		i;
	LPFRAME 	lpFrame;
	int 		Width;
	int 		Height;
	int 		x,y;
	LPTR 		lpSrcLine;
	BYTE 		r, g, b;

	iActiveDot = 0;
	iNumDots = 0;

// Clear out the array	
	for (i=0; i<MAX_DOTS; i++)
	{
		DotPoints[i].x = 0;
		DotPoints[i].y = 0;
	}

    if (!lpImage) return;
    lpFrame = ImgGetBaseEditFrame(lpImage);
    if (!lpFrame) return;
    Width  = FrameXSize (lpFrame);
    Height = FrameYSize (lpFrame);

// Find all the points in the image.
// Search for coded dots that indicate a dot-to-dot point.
// These dot points will be drawn as circles for the user to click in.
// An array of points - DotPoints[] is maintained to remember these dots.
    for (y=0;y<Height;y++)
    {
	    AstralClockCursor( y, Height, NO );
        lpSrcLine = FramePointer (lpFrame,0,y,FALSE);

        for (x=0;x<Width;x++)
        {
            RGBS Pixel;
            FrameGetRGB (lpFrame,lpSrcLine,&Pixel,1);
            r = Pixel.red;
            g = Pixel.green;
            b = Pixel.blue;
            if (r >= 100 && g == 0 && b == 0)
            {
            	// This is a coded pixel that contains:
            	//  1) green - No coding.  MUST be 0.
            	//  2) red   - Sequence that the dot is found.
            	//  3) blue  - No coding.  MUST be 0.
				r -= 100;
				if (r >= 0 && r <= MAX_DOTS)
				{
					// Save the Dot position.
					// Do not allow the dot to go off the screen.
					DotPoints[r].x = min(x, Width  - ((DOT_DIAMETER / 2) + 2));
					DotPoints[r].y = min(y, Height - ((DOT_DIAMETER / 2) + 2));
					iNumDots = max(iNumDots, r);
				}
            }
            lpSrcLine += 3;
        } // Width
    }     // Height
}
示例#16
0
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 );
}
示例#17
0
void ImgInitDisplay(LPIMAGE lpImage, BOOL fGeneratePaletteLUT)
/***********************************************************************/
{
LPTR lpPaletteLUT;
RGBS RGBmap[256];
LPRGB lpRGBmap;
int nColors;
FRMTYPEINFO TypeInfo, DstTypeInfo = ColorManager.Monitor.dst;
LPOBJECT lpObject;

lpObject = lpImage->GetDisplayObject();
if (!lpObject)
	return;
FrameGetTypeInfo(ObjGetEditFrame(lpObject), &TypeInfo);

if ( lpBltScreen->BitMapInfo.bmiHeader.biBitCount == 8 &&
        !lpImage->lpPaletteLUT)
    {
    ProgressBegin(1, PROGRESS_ID(IDS_UNDOSETUPDISPLAY));
    if (TypeInfo.DataType == FDT_PALETTECOLOR)
        lpPaletteLUT = Alloc(32768L);
    else
        lpPaletteLUT = NULL;
    if (lpPaletteLUT)
        {
        if (TypeInfo.ColorMap->NumEntries > MAX8BITCOLORS)
            {
            nColors = MAX8BITCOLORS;
            lpRGBmap = RGBmap;
            if (!ReducePalette(TypeInfo.ColorMap->RGBData,  TypeInfo.ColorMap->NumEntries,
                                lpRGBmap, nColors))
                {
                FreeUp(lpPaletteLUT);
                lpPaletteLUT = NULL;
                }
            }
        else
            {
            lpRGBmap = TypeInfo.ColorMap->RGBData;
            nColors = TypeInfo.ColorMap->NumEntries;
            }
        }
    if (lpPaletteLUT)
        {
		if (fGeneratePaletteLUT)
	        CreatePaletteLut15(lpRGBmap, nColors, lpPaletteLUT, AstralClockCursor);
        lpImage->lpPaletteLUT = lpPaletteLUT;
        lpImage->PaletteType = PT_CUSTOMPALETTE;
        lpImage->hPal = CreateLogicalPalette(lpRGBmap, nColors);
		  GetObject(lpImage->hPal, sizeof(nColors), (void *)&nColors);
        lpImage->nPaletteEntries = GetPaletteEntries(lpImage->hPal,
                        0, nColors, lpImage->Palette);
        }
    else
        {
        if ( FrameType(ImgGetBaseEditFrame(lpImage)) <= FDT_GRAYSCALE)
            {
            lpImage->hPal = lpBltScreen->hGrayPal;
            lpImage->nPaletteEntries = lpBltScreen->nGrayEntries;
            lpImage->PaletteType = lpBltScreen->GrayPaletteType;
            lpImage->lpPaletteLUT = lpBltScreen->lpGrayPaletteLUT;
            copy((LPTR)lpBltScreen->GrayPalette,
                 (LPTR)lpImage->Palette,
                 sizeof(lpImage->Palette));
            }
        else
            {
            lpImage->hPal = lpBltScreen->hColorPal;
            lpImage->nPaletteEntries = lpBltScreen->nColorEntries;
            lpImage->PaletteType = lpBltScreen->ColorPaletteType;
            lpImage->lpPaletteLUT = lpBltScreen->lpColorPaletteLUT;
            copy((LPTR)lpBltScreen->ColorPalette,
                 (LPTR)lpImage->Palette,
                 sizeof(lpImage->Palette));
            }
        }
    ProgressEnd();
    }

if (lpImage->m_cmsXform)
	{
	if( Control.CMSEnabled && lpKCMSFreeProc )
		{
		if (lpImage->PtInfo.toRCS != TypeInfo.ptInfo.toRCS &&
			lpImage->PtInfo.frRCS != TypeInfo.ptInfo.frRCS )
			{
			( lpKCMSFreeProc )( lpImage->m_cmsXform );
			lpImage->m_cmsXform = NULL;
			}
		}
	else
		lpImage->m_cmsXform = NULL;
	}

	
if( Control.CMSEnabled &&
	IsSrcPTSelected( &TypeInfo.ptInfo ) &&
	IsDstPTSelected( &DstTypeInfo.ptInfo ) &&
	lpKCMSCnctProc )
	{
	lpImage->m_bDoCmsGamma = YES;
	if (!lpImage->m_cmsXform)
		{
		if( ( !FrameTypeInfoEqual( TypeInfo, DstTypeInfo ) ) &&
				ConvertCRCtoUID( &TypeInfo, &DstTypeInfo ) )
			{
			// save for later check to avoid a monitor reconnect.
			lpImage->PtInfo = TypeInfo.ptInfo;
			lpImage->m_cmsXform = ( *lpKCMSCnctProc )( &TypeInfo, &DstTypeInfo );
			}
		else
			lpImage->m_cmsXform = NULL;
		}
	}
else
	lpImage->m_cmsXform = NULL;
}
示例#18
0
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 ) );
}
示例#19
0
void grabber( LPSTR lpExtName, int port, HINSTANCE hInstance, HWND hWindow )
{

	HWND hWnd;
/*
	special conditions:
		hand scan interface --	
			with hand scanners the dialog box has a scan
			frame which gets filled with image data.  the
			dialog box must remain up during reads, so we
			use the exported frame_open, cacheptr, and
			frame_close to create the frame instead of 
			device reads.  Devopen just returns devcaps,
			devstart does everything else.
	
		special willow gs --	
			the gs board has 4 different buffers, which
			contain the following: 0-even pix/even lines,
			1-odd pix/even lines, 2-even pix/odd lines,
			3-odd pix/odd lines.
			each call to devread will layer the data so
			that the buffers will be combined correctly.
	
	Device Requirements Byte Decoding:

		XXXXXXX1b =  need to take over display
		XXXXXXX0b =  no need to take over display
		XXXXXX1Xb =  special willow gs read
		XXXXXX0Xb =  no special read 
		XXXX00XXb =  image depth, special case palette color 8-bit
		XXXX01XXb =  depth == 1
		XXXX10XXb =  depth == 2
		XXXX11XXb =  depth == 3
		X1XXXXXXb = special hand scan i/f 
		X0XXXXXXb = standard grab i/f
		XX1XXXXXb = don't free DLL after exit
		XX0XXXXXb = free DLL after exit 
		1XXXXXXXb = putting data from cache to external device
		0XXXXXXXb = putting data from external device into cache
		*/

	BYTE devreq; // device requirements
	LPFRAME lpFrame, lpOldFrame;
	BYTE depth;
	int lncnt,Datatype;
	HMODULE hDLL;
	LPIMAGE lpImage;

	if ( !(hDLL = (HMODULE)LoadGrabberLibrary(lpExtName)) ) {
		Message( IDS_EBADDRIVER, NULL );
		return;
	}

	if ( !(lpImage = GetActiveImage()))
		lpFrame = NULL;
	else
		lpFrame = ImgGetBaseEditFrame(lpImage);

   lpfnDevName     = (DEVNAMEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(301));
   lpfnDevOpen     = (DEVOPENPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(302));
   lpfnDevCall     = (DEVCALLPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(303));
   lpfnDevClose    = (DEVCLOSEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(304));
   lpfnAcquireProc = (DLGPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(305));

	/* get device's intentions -- is this a put to or read from cache */
	DevInfo.hInst = hInstance;  /* set the data structures */
	DevInfo.hPw = hWindow;
	DevInfo.bFile_is_open = ( lpFrame != NULL );

	if(DevInfo.bFile_is_open)
		{
		DevInfo.bImg_type = (lpImage->DataType==IDC_SAVECT ? TRUE : FALSE);
		/* pass the current filename */
		lstrcpy(DevInfo.cfname, lpImage->CurFile); 
		}

	if(!DevOpen(&DevInfo)) {
		DevCall(DEV_MSG, (LPTR)&DevMsg);
		
		/* if MsgNo == 0, then user cancelled */
		if(DevMsg.MsgNo) {
			if(DevMsg.MsgNo > 0) {
				Message( DevMsg.MsgNo );
			} else {
				/* print the driver's message */
				Print("%ls", (LPTR)DevMsg.szMsg);
			}
		}
		return; 
	}

	bKeepDLL = (DevInfo.device_caps & 0x20);
	devreq = DevInfo.device_caps;
	
	/* doing a put cache to an external device */
	if(!(devreq & 0x80)) {
		/* fill up the device info data structure */
		DevInfo.npix = FrameXSize( lpFrame );
		DevInfo.nlin = FrameYSize( lpFrame );
		DevInfo.bpl =  FrameXSize( lpFrame );
		DevInfo.xres = DevInfo.yres = FrameResolution( lpFrame );
		DevInfo.bpp = 8;
	} else {
		DevInfo.port = port; /* set the port for devices which require it */
#ifndef WIN32
		DevInfo.vgaaddr = GetA000H(); /* set the VGA buffer address */
#endif
	}

	/* see if we need to take over display */
	if(devreq & 1) {
		/* Hide the Cursor */
		ShowCursor( FALSE );

		/* Create the acquire window: it doesn't have the visable bit set */
		AstralDlg( YES, hInstance, hWindow, IDD_GRAB, AcquireProc);
		AstralDlgShow( IDD_GRAB );

		/* Enter the picture window command processor */
		SetCapture( AstralDlgGet( IDD_GRAB ) );

		/* set the data structures */
		DevInfo.hInst = hInstance;  
		DevInfo.hPw   = AstralDlgGet( IDD_GRAB );

		/* call display driver disable */
#ifndef WIN32
		PicwinOn((LPSTR)palette1);
#endif
	}

	if(devreq & 0x40) { // devstart does everything
		DevInfo.FpPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_ptr, DevInfo.hInst);

		DevInfo.FoPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_open, DevInfo.hInst);

		DevInfo.FsPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_set, DevInfo.hInst);

		DevInfo.FcPtr = (LPROC)MakeProcInstance(
			(FARPROC)grabber_frame_close, DevInfo.hInst);

		DevInfo.CcPtr = (LPROC)MakeProcInstance(
			(FARPROC)grabber_AstralClockCursor, DevInfo.hInst);
	}

	DevInfo.bLineArtAsGray = Control.LineArtAsGray;
 
	if(!DevCall(DEV_START, (LPTR)&DevInfo)) { /* if get, fill struct */
		back_to_windows(devreq & 1); /* restore if true */

		DevCall(DEV_MSG, (LPTR)&DevMsg);

		/* if MsgNo == 0, then user cancelled */
		if(DevMsg.MsgNo) {
			if(DevMsg.MsgNo > 0) {
				Message( DevMsg.MsgNo );
			} else {
				/* print the driver's message */
				Print("%ls", (LPTR)DevMsg.szMsg);
			}
		}

		if(devreq & 0x40) { // devstart does everything
			FreeProcInstance((FARPROC)DevInfo.FpPtr);
			FreeProcInstance((FARPROC)DevInfo.FoPtr);
			FreeProcInstance((FARPROC)DevInfo.FsPtr);
			FreeProcInstance((FARPROC)DevInfo.FcPtr);
			FreeProcInstance((FARPROC)DevInfo.CcPtr);
		}

		DevClose(); /* close the device */
		return;
	}

	/* DEV_START returned ok, now get or put image data if not done */

	if((devreq & 0xc0) == 0x80) { // putting data into the cache with devreads
		if(((devreq & 4) == 4) || ((devreq & 0x0c) == 0)) {
			depth = 1;
		} else {
			if((devreq & 8) == 8) {
				depth = 2;
			} else {
				if((devreq & 0x0c) == 0x0c) {
					depth = 3;
				}
			}
		}

		lpOldFrame = frame_set( NULL );
	
		if(!(lpFrame = FrameOpen(
				(FRMDATATYPE)depth,DevInfo.npix,DevInfo.nlin,DevInfo.xres))) {

			back_to_windows(devreq & 1); /* Restore if true */
	
			FrameError(IDS_EIMAGEOPEN);
			return;
		}
	
		frame_set(lpFrame);
	
		if(!(devreq & 2))	{
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ, (LPTR)&DevData)) {
		         back_to_windows(devreq & 1); /* Restore if true */
					DevCall(DEV_MSG, (LPTR)&DevMsg);
	
					/* if MsgNo == 0, then user cancelled */
					if(DevMsg.MsgNo) {
						Print("Unable to get data from device");
					} else {
						DevInfo.nlin = lncnt;  // hand scanner, get total lines
					}
					return;
				}
			}
		} else { /* special willow gs reader */
	
			/* read even bytes, even lines */
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ0, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read odd bytes, even lines */
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES);
				if(!DevCall(DEV_READ1, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read even bytes, odd lines */
			for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ2, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read odd bytes, odd lines */
			for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES);
				if(!DevCall(DEV_READ3, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
		}
		
		FrameClose( lpOldFrame );
	
		back_to_windows(devreq & 1); /* Restore if true */
	
		if(DevInfo.bpp == 1) {
			Datatype = IDC_SAVELA;
		} else {
			if(DevInfo.bpp == 8) {
				Datatype = IDC_SAVECT;
			} else {
				Datatype = IDC_SAVE24BITCOLOR;
			}
		}
	
		/* Setup the new image and bring up the new image window */
        LPIMAGE lpNewImage = CreateImage(NULL, lpFrame, NULL, 
           NULL, Control.DefaultFileType, Datatype, 
           IMG_DOCUMENT, NULL);
        if (lpNewImage)
        {
            if (PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
               lpNewImage))         
            {
               	/* only version of image is in the cache */
            	/* so insure user is asked about saving when done */
                lpNewImage->fChanged = TRUE;
            }
            else
                DestroyImage(lpNewImage);
        }
	
		DevClose(); /* close the device */
	} else {
        LPIMAGE lpNewImage = NULL;

		/* enable the frame created by DevStart */
		lpFrame = frame_set(NULL);

		/* putting data to external device with DevWrites */
		if((devreq & 0xc0) == 0) {
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) {
				AstralClockCursor( lncnt, DevInfo.nlin, NO );
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, NO);
				if(!DevCall(DEV_WRITE, (LPTR)&DevData)) {
					Print("Unable to put data to device");
					return;
				}
			}
		} else {
			/* devstart has created a frame with image data */
			FreeProcInstance((FARPROC)DevInfo.FpPtr);
			FreeProcInstance((FARPROC)DevInfo.FoPtr);
			FreeProcInstance((FARPROC)DevInfo.FsPtr);
			FreeProcInstance((FARPROC)DevInfo.FcPtr);

			if(DevInfo.bpp == 1) {
				Datatype = IDC_SAVELA;
			} else {
				if(DevInfo.bpp == 8) {
					Datatype = IDC_SAVECT;
				} else {
					Datatype = IDC_SAVE24BITCOLOR;
				}
			}

			back_to_windows(devreq & 1); /* Restore if true */

			/* enable the frame created by DevStart */
			lpFrame = frame_set(NULL);

			/* DevInfo.nlin returns the actual line count */
			if(FrameYSize(lpFrame) <= DevInfo.nlin) {
				/* Setup the new image and bring up the new image window */
            {
                lpNewImage = CreateImage(NULL, lpFrame, NULL, 
                   NULL, Control.DefaultFileType, Datatype, 
                   IMG_DOCUMENT, NULL);
                if (lpNewImage)
                {
                    if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
                       lpNewImage))         
                    {
                        DestroyImage(lpNewImage);
                        lpNewImage = NULL;
                    }
                }
            }

			} else {
				/* create a new frame of the right size and copy  */
				/* the right number of lines to it */

				lpOldFrame = FrameOpen(
					FrameType(lpFrame),
					FrameXSize(lpFrame), 
					DevInfo.nlin,
					FrameResolution(lpFrame));

				AstralCursor( IDC_WAIT );

				for(lncnt=0; lncnt<DevInfo.nlin; lncnt++) {
					FrameCopyLine(lpFrame, lpOldFrame, lncnt);
				}

				FrameClose(lpFrame);
				lpFrame = lpOldFrame;
				AstralCursor( NULL );
				/* Setup the new image and bring up the new image window */
                lpNewImage = CreateImage(NULL, lpFrame, NULL, 
                   NULL, Control.DefaultFileType, Datatype, 
                   IMG_DOCUMENT, NULL);
                if (lpNewImage)
                {
                    if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
                       lpNewImage))         
                    {
                        DestroyImage(lpNewImage);
                        lpNewImage = NULL;
                    }
                }

			}
			/* only version of image is in the cache */
			/* so insure user is asked about saving when done */
            if (lpNewImage)    
                lpNewImage->fChanged = TRUE;

			DevClose(); /* close the device */
		}
	}
}
示例#20
0
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);
}
示例#21
0
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 );
}
示例#22
0
void VignetteProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option )
/************************************************************************/
{
RECT Rect;
BOOL fShift;
POINT pt;
static int Type, Style;
static BOOL fConstrain;
static RECT SelectRect;
int res;
FRMDATATYPE type;
LPIMAGE lpImage;
STRING szString;
GRADIENT_PARMS parms;

switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!IsOnImage(hWindow, x, y))
		break;
	ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &type);
	if (type == FDT_LINEART)
		{
		AstralStrEx( IDC_TOOLNAMESTART+IDC_VIGNETTE, szString, sizeof(szString) );
		Message(IDS_NOTWITHLINEART, (LPSTR)szString);
		break;
		}
	AstralUpdateWindow(hWindow);
	Tool.bActive = YES;
//	SetMaskingState( x, y );
	break;

    case WM_LBUTTONDOWN:
	Type = Vignette.Gradient;
	fConstrain = ( Type == IDC_VIGSQUARE || Type == IDC_VIGCIRCLE );
	AstralSetRectEmpty( &SelectRect );
	if ( Type == IDC_VIGCIRCLE || Type == IDC_VIGELLIPSE )
		Style = SL_ELLIPSE;
	else
	if ( Type == IDC_VIGRADIAL || Type == IDC_VIGLINEAR )
		Style = SL_LINE;
	else
		Style = SL_BOX;
	pt.x = x; pt.y = y;
	StartSelection( hWindow, NULL, &SelectRect, Style | SL_SPECIAL,
		pt, 0L );
	break;

    case WM_LBUTTONUP:
	Tool.bActive = NO;
	Rect = SelectRect; // make a copy before it gets ordered
	EndSelection( hWindow, NULL, &SelectRect, Style, YES );
    lpImage = (LPIMAGE)GetImagePtr ( hWindow );
	res = FrameResolution(ImgGetBaseEditFrame(lpImage));
	type = FrameType(ImgGetBaseEditFrame(lpImage));

	parms.VigOpacity = Vignette.VigOpacity;
	parms.VigMergeMode = Vignette.VigMergeMode;
	parms.iBaseRes = res;
	parms.x1 = Rect.left;
	parms.y1 = Rect.top;
	parms.x2 = Rect.right;
	parms.y2 = Rect.bottom;
	GetActiveColorFromType(type, &parms.StartColor);
	GetAlternateColorFromType(type, &parms.EndColor);
	parms.Gradient = Vignette.Gradient;
	parms.RepeatCount = Vignette.RepeatCount;
	parms.SoftTransition = Vignette.SoftTransition;
	parms.Midpoint = Vignette.Midpoint;
	parms.VigColorModel = Vignette.VigColorModel;
	ProcessCommand(lpImage->lpCmdList, IDS_CMD_GRADIENT, &parms);
	break;

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	fShift = SHIFT;
	pt.x = x; pt.y = y;
	UpdateSelection( hWindow, NULL, &SelectRect, Style,
		pt, fConstrain^CONSTRAINASPECT, 1L, 1L,
		MOVEKEY||Window.fRButtonDown, FROMCENTER);
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	if (!Tool.bActive)
		break;
	Tool.bActive = NO;
	EndSelection( hWindow, NULL, &SelectRect, Style, YES );
	break;
    }
}
示例#23
0
BOOL GradientImage( LPIMAGE lpImage, LPGRADIENT_PARMS lpParms)
{
	LPFRAME lpFrame;
	RECT rMask;
	LPINT lpD;
	FRMTYPEINFO TypeInfo;
	int dx, dy, iCount;
	int index, prev, next, pi, ni;
	long ldx, ldy, x, y, xs, xe, ys, ye, asqrd, bsqrd, r;
	LPDATAPROC lpVignetteProc;
	ENGINE Engine;
	BOOL   DoHSL;
	GRADIENT_DATA data;
	int res;

   FRMDATATYPE type;
	ImgGetInfo(lpImage, NULL, NULL, NULL, &type);
	if (type == FDT_LINEART)
		return(FALSE);
	if (!(lpFrame = ImgGetBaseEditFrame(lpImage)))
		return(FALSE);
	res = FrameResolution(lpFrame);
	data.x1 = lpParms->x1;
	data.y1 = lpParms->y1;
	data.x2 = lpParms->x2;
	data.y2 = lpParms->y2;
	ResConvertUL(lpParms->iBaseRes, res, &data.x1, &data.y1);
	ResConvertLR(lpParms->iBaseRes, res, &data.x2, &data.y2);
	dx = data.x2 - data.x1;
	dy = data.y2 - data.y1;
	data.SoftTransition = lpParms->SoftTransition;
	data.lpPaletteLUT = NULL;

	if (lpParms->Gradient == IDC_VIGLINEAR || lpParms->Gradient == IDC_VIGRADIAL)
	{
		if (abs(dx) <= 3 && abs(dy) <= 3)
			return(FALSE);
	}
	else
	{
		if (abs(dx) <= 3 || abs(dy) <= 3)
			return(FALSE);
	}

	data.xc = (data.x1 + data.x2) / 2;
	data.yc = (data.y1 + data.y2) / 2;

	if ( (data.nRepetitions = lpParms->RepeatCount) <= 0 )
		data.nRepetitions = 1;

	FrameGetTypeInfo(lpFrame, &TypeInfo);

	DoHSL = (lpParms->VigColorModel+IDC_FIRST_MODEL) != IDC_MODEL_RGB &&
				(TypeInfo.DataType > FDT_GRAYSCALE);

	switch (lpParms->Gradient)
	{
		case IDC_VIGLINEAR:
			data.D = lsqrt(((long)dx*(long)dx)+((long)dy*(long)dy));
			data.sine = FGET(-dy, data.D);
			data.cosine = FGET(dx, data.D);
			data.xr = WHOLE(( rotx(data.x2, data.y2, data.x1, data.y1,
            data.cosine, data.sine) ));
			lpVignetteProc = (LPDATAPROC)linear_vignette_proc;
		break;

		case IDC_VIGRADIAL:
			data.D = lsqrt(((long)dx*(long)dx)+((long)dy*(long)dy));
			lpVignetteProc = (LPDATAPROC)radial_vignette_proc;
		break;

		case IDC_VIGCIRCLE:
			data.x1 = data.xc;
			data.y1 = data.yc;
			data.y2 = data.yc;
			dx = data.x2 - data.x1;
			dy = data.y2 - data.y1;
			if (!dx && !dy)
				return(FALSE);
			data.D = lsqrt(((long)dx*(long)dx)+((long)dy*(long)dy));
			lpVignetteProc = (LPDATAPROC)radial_vignette_proc;
		break;

		case IDC_VIGSQUARE:
		case IDC_VIGRECTANGLE:
			data.ymin = min(data.y1, data.y2);
			data.ymax = max(data.y1, data.y2);
			data.xmin = min(data.x1, data.x2);
			data.xmax = max(data.x1, data.x2);

			ldx = data.xmin-data.xc;		// upper left
			ldy = data.ymin-data.yc;
			data.m1 = (256L * ldy) / ldx;
			data.b1 = data.ymin - ((data.m1 * data.xmin)/256L);
			data.D1 = lsqrt((ldx*ldx)+(ldy*ldy));

			ldx = data.xmax-data.xc;		// upper right
			ldy = data.ymin-data.yc;
			data.m2 = (256L * ldy) / ldx;
			data.b2 = data.ymin - ((data.m2 * data.xmax)/256L);
			data.D2 = lsqrt((ldx*ldx)+(ldy*ldy));

			ldx = data.xmax-data.xc;		// lower right
			ldy = data.ymax-data.yc;
			data.m3 = (256L * ldy) / ldx;
			data.b3 = data.ymax - ((data.m3 * data.xmax)/256L);
			data.D3 = lsqrt((ldx*ldx)+(ldy*ldy));

			ldx = data.xmin-data.xc;		// lower left
			ldy = data.ymax-data.yc;
			data.m4 = (256L * ldy) / ldx;
			data.b4 = data.ymax - ((data.m4 * data.xmin)/256L);
			data.D4 = lsqrt((ldx*ldx)+(ldy*ldy));

			lpVignetteProc = (LPDATAPROC)rectangle_vignette_proc;
		break;

		case IDC_VIGELLIPSE:
			if ( !(data.lpD = (LPINT)Alloc((long)sizeof(int)*(TSIZE+1))) )
			{
				Message(IDS_EMEMALLOC);
				return(FALSE);
			}
			iCount = TSIZE+1;
			lpD = data.lpD;
			while (--iCount >= 0)
				*lpD++ = -1;				
			data.ymin = min(data.y1, data.y2);
			data.ymax = max(data.y1, data.y2);
			data.xmin = min(data.x1, data.x2);
			data.xmax = max(data.x1, data.x2);
			data.ea = dx/2;
			data.eb = dy/2;
			if (!data.ea || !data.eb)
			{
				FreeUp((LPTR)data.lpD);
				return(FALSE);
			}
			asqrd = data.ea*data.ea;
			bsqrd = data.eb*data.eb;

			// fill in a table with radius information for the
			// ellipse.  The radius for a given point would be
			// starting from the center of the ellipse, going 
			// through to point, and where it intersects the 
			// edge of the ellipse.  We need the radius for
			// the D value used in the ellipse_proc, which is
			// the maximum distance used for determining how to
			// calculate the gradient, which is d/D.  d is the 
			// distance of the point from the center, D is extracted
			// from the table built below.  The index of the table is
			// formed from the ratio of sides of the triangle formed.
			// This is like looking up the angle to see where the
			// point would intersect the circle.  But we calculate
			// the radii ahead of time to speed things up.
			if (data.ea > data.eb)	// step in x
			{
				xs = data.xc - data.xc;
				xe = data.xmax - data.xc;
				for (x = xs; x <= xe; ++x)
				{
					y = ((data.eb*(long)lsqrt(asqrd - (x*x)))+(data.ea/2))/data.ea;
					r = (x*x)+(y*y);
					if (r <= 0)
						r = 1;
					index = ((x * x * (long)TSIZE)+(r/2)) / r;
					index = bound(abs(index), 0, TSIZE);
					data.lpD[index] = lsqrt(r);
				}
			}
			else		// step in y
			{
				ys = data.yc - data.yc;
				ye = data.ymax - data.yc;
				for (y = ys; y <= ye; ++y)
				{
					x = ((data.ea*(long)lsqrt(bsqrd - (y*y)))+(data.eb/2))/data.eb;
					r = (x*x)+(y*y);
					if (r <= 0)
						r = 1;
					index = ((y * y * (long)TSIZE)+(r/2)) / r;
					index = bound(abs(index), 0, TSIZE);
					data.lpD[index] = lsqrt(r);
				}
			}
			// find the first valid entry in our table
			for (index = 0; index <= TSIZE && data.lpD[index] < 0; ++index)
				;

			// see if we have any entries
			if (index > TSIZE)
			{
				FreeUp((LPTR)data.lpD);
				return(FALSE);
			}

			// fill in all entries before first with value of first
			while (--index >= 0)
				data.lpD[index] = data.lpD[index+1];

			// find last valid entry in table
			for (index = TSIZE; index >= 0 && data.lpD[index] < 0; --index)
				;

			// see if we have any entries
			if (index < 0)
			{
				FreeUp((LPTR)data.lpD);
				return(FALSE);
			}

			// fill in all entries after last with value of last
			while (++index <= TSIZE)
				data.lpD[index] = data.lpD[index-1];

			// interpolate values of all empty cells
			for (index = 0; index <= TSIZE; ++index)
			{
				if (data.lpD[index] < 0)
				{
					pi = index - 1;
					prev = data.lpD[pi];
					ni = index;
					while (data.lpD[ni] < 0)
						++ni;
					next = data.lpD[ni];
					// remember here that (index-pi) == 1
					data.lpD[index] = prev + ((next-prev)/(ni-pi));
				}
			}
			lpVignetteProc = (LPDATAPROC)ellipse_vignette_proc;
		break;

		default:
			return(FALSE);
		break;
	}

	switch(TypeInfo.DataType)
	{
		case FDT_LINEART :
		case FDT_GRAYSCALE :
			data.lpProcessProc = (LPVIGPROC)ProcessVignette8;
		break;

		case FDT_PALETTECOLOR:
			data.lpProcessProc = (LPVIGPROC)ProcessVignette8P;
			data.lpPaletteLUT = CreatePaletteLut15(TypeInfo.ColorMap->RGBData,
					TypeInfo.ColorMap->NumEntries, NULL, NULL);
		break;

		case FDT_RGBCOLOR :
			data.lpProcessProc = (LPVIGPROC)ProcessVignette24;
		break;

		case FDT_CMYKCOLOR :
			data.lpProcessProc = (LPVIGPROC)ProcessVignette32;
		break;
	}

	data.lpMidpointTable = BuildMidPointTable(
							DoHSL,
							TypeInfo.DataType,
							lpParms->Midpoint,
							&lpParms->StartColor,
							&lpParms->EndColor,
							&data );

	ImgGetMaskRect( lpImage, &rMask );
	data.lplD = (LPLONG)Alloc((long)sizeof(long)*(long)RectWidth(&rMask));
	data.lpld = (LPLONG)Alloc((long)sizeof(long)*(long)RectWidth(&rMask));

	if (!data.lpld || !data.lplD || !data.lpMidpointTable ||
		(TypeInfo.DataType == FDT_PALETTECOLOR && !data.lpPaletteLUT))
	{
		if (lpParms->Gradient == IDC_VIGELLIPSE)
			FreeUp((LPTR)data.lpD);
		if (data.lplD)
			FreeUp((LPTR)data.lplD);
		if (data.lpld)
			FreeUp((LPTR)data.lpld);
		if (data.lpMidpointTable)
			FreeUp((LPTR)data.lpMidpointTable);
		if (data.lpPaletteLUT)
			FreeUp(data.lpPaletteLUT);
		return(FALSE);
	}

	SetEngineDraw(&Engine,lpVignetteProc,lpParms->VigOpacity,lpParms->VigMergeMode);
	Engine.lpParam = &data;
	Engine.fThread = NO;
	lpParms->Common.StatusCode = LineEngineSelObj(lpImage,&Engine,lpParms->Common.idDirty);
	if (!AstralIsRectEmpty(&Engine.rUpdate))
	{
		lpParms->Common.UpdateType = UT_AREA;
		lpParms->Common.rUpdateArea = Engine.rUpdate;
	}

	FreeUp((LPTR)data.lpld);
	FreeUp((LPTR)data.lplD);
	FreeUp((LPTR)data.lpMidpointTable);
	if (data.lpPaletteLUT)
		FreeUp(data.lpPaletteLUT);

	if (lpParms->Gradient == IDC_VIGELLIPSE)
		FreeUp((LPTR)data.lpD);
	return(lpParms->Common.StatusCode == SC_SUCCESS);
}
示例#24
0
static BOOL FAR MazeToolProc (HWND hWnd,LONG lParam,WORD wMsg)
{
    HDC     hDC;
    LPFRAME lpFrame;
    LPTR    lpLine;
    POINT   pt;
    RGBS    Pixel;
    static int x1,y1;

    pt.x = LOWORD(lParam);
    pt.y = HIWORD(lParam);
    switch (wMsg)
    {
    case WM_LBUTTONDOWN:
        if (!bTrack)
        {
            lpFrame = ImgGetBaseEditFrame (lpImage);
            lpLine = FramePointer (lpFrame,pt.x,pt.y,FALSE);
            FrameGetRGB (lpFrame,lpLine,&Pixel,1);
            if (Pixel.green && !(Pixel.red & Pixel.blue)) // start green pel
            {
//                SoundStartID (IDC_LINES,NO,0);
                SoundStartResource ("icons",NO,0);
                MazeTrailPoints[0].x = x1 = pt.x;
                MazeTrailPoints[0].y = y1 = pt.y;
                nNumTrailPoints = 1;
                if (bShowSolution || bSolved)
                {
                    bShowSolution = bSolved = FALSE;
                    InvalidateRect (hWnd,NULL,FALSE);
                    UpdateWindow (hWnd);
                }
                bTrack = TRUE;
            }
            else if (!AnimateProc(hWnd,lParam,wMsg))
                SoundStartResource ("WRONGANSWER1",NO,0);
        }
        break;
    case WM_MOUSEMOVE:
        if (!bTrack)
            break;
        if (!fAppActive || GetUpdateRect (hWnd,NULL,FALSE))
        {
            InvertLine (hWnd,x1,y1,x1,y1);
            break;
        }
        InvertLine (hWnd,x1,y1,pt.x,pt.y);
        if (!LBUTTON || (pt.x == x1 && pt.y == y1))
            break;
        // else button is down, so fall through to anchor a point
    case WM_LBUTTONUP:
        if (bTrack)
        {
            if (PathIsClear (x1,y1,pt.x,pt.y))
            {
                lpFrame = ImgGetBaseEditFrame (lpImage);
                lpLine = FramePointer (lpFrame,pt.x,pt.y,FALSE);
                FrameGetRGB (lpFrame,lpLine,&Pixel,1);
                if (Pixel.red && !(Pixel.green & Pixel.blue)) // end red pel
                {
                    SoundStartResource ("GOODANSWER1",NO,0);
					StartAnimation(hWnd);
                    bSolved = TRUE;
                    bTrack = FALSE;
                }
                else
                {
                    hDC = GetDC (hWnd);
                    DrawLineEx (hDC,x1,y1,pt.x,pt.y,
                        hMazePen ? hMazePen : (HPEN)GetStockObject (BLACK_PEN),FALSE);
                    ReleaseDC (hWnd,hDC);
                    x1 = pt.x;
                    y1 = pt.y;
                    if (nNumTrailPoints < MAX_LINEPOINTS)
                    {
                        MazeTrailPoints[nNumTrailPoints].x = x1;
                        MazeTrailPoints[nNumTrailPoints].y = y1;
                        nNumTrailPoints++;
                    }
                }
            }
            else
                SoundStartResource ("WRONGANSWER1",NO,0);
        }
        break;
    case WM_PAINT:
        if (bTrack)
        {
            int i;

            hDC = GetDC (hWnd);
            pt.x = MazeTrailPoints[0].x;
            pt.y = MazeTrailPoints[0].y;
            for (i = 1; i < nNumTrailPoints; i++)
            {
                DrawLineEx (hDC,pt.x,pt.y,
                    MazeTrailPoints[i].x,MazeTrailPoints[i].y,
                    hMazePen ? hMazePen : (HPEN)GetStockObject (BLACK_PEN),FALSE);
                pt.x = MazeTrailPoints[i].x;
                pt.y = MazeTrailPoints[i].y;
            }
            ReleaseDC (hWnd,hDC);
        }
        break;
    }
    return TRUE;
}
示例#25
0
/************************************************************

 	SaveWallpaper

	  	Saves the current picture into the specified file.
		Installs it as the system wallpaper (uses name given).
		Sets the INI tiled flag to the passed value

		returns FALSE if it could not save wallpaper.
************************************************************/
BOOL SaveWallpaper( LPSTR lpName, BOOL fTiled )
{
WORD idDataType;
STRING szSaveAs;
LPFRAME lpFrame;
int nBits, nPlanes, nDepth, nOutWidth, nOutHeight;

if ( !lpImage )
	return(FALSE);
if ( !(lpFrame = ImgGetBaseEditFrame(lpImage)) )
	return(FALSE);

AstralCursor( IDC_WAIT );	/* Put up the wait cursor */

nBits = GetDeviceCaps( Window.hDC, BITSPIXEL );
nPlanes = GetDeviceCaps( Window.hDC, PLANES );
nDepth = nBits * nPlanes;
nOutWidth = GetDeviceCaps( Window.hDC,HORZRES);
nOutHeight = GetDeviceCaps( Window.hDC,VERTRES);

// decide on proper depth
if ( FrameType(lpFrame) == FDT_LINEART )
	idDataType = IDC_SAVELA;
else
if (nDepth <= 4)
	{
  	if( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVESP;
	else
		idDataType = IDC_SAVE4BITCOLOR;
	}
else
if( nDepth <= 8 || !Control.Save24BitWallpaper)
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE8BITCOLOR;
	}
else
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE24BITCOLOR;
	}

// Save file into the Windows directory
GetWindowsDirectory(szSaveAs, sizeof(FNAME));
FixPath( szSaveAs );
lstrcat( szSaveAs, filename(lpName) );
stripext( szSaveAs );
lstrcat( szSaveAs, ".BMP" );

if ( !AstralImageSave( IDN_BMP, idDataType, szSaveAs ) )
	goto ErrorExit;

// Make szSaveAs the current wallpaper and apply
WriteProfileString( "Desktop", "TileWallPaper", (fTiled?"1":"0") );
SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename(szSaveAs),
	SPIF_UPDATEINIFILE );
AstralCursor( NULL ); /* Revert back to the old cursor */
return (TRUE);

ErrorExit:

AstralCursor( NULL ); /* Revert back to the old cursor */
return(FALSE);
}
示例#26
0
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 );
}