Exemplo n.º 1
0
BOOL InvertImage(LPIMAGE lpImage, LPCMD_PARMS lpParms)
{
	ENGINE Engine;
	FRMTYPEINFO TypeInfo;
	LPCOLORMAP lpColorMap;

	ImgGetTypeInfo(lpImage, &TypeInfo);
	if (TypeInfo.DataType == FDT_PALETTECOLOR)
	{
		lpColorMap = FrameCopyColorMap(TypeInfo.ColorMap);
		if (!lpColorMap)
			{
			Message(IDS_EMEMALLOC);
			lpParms->Common.StatusCode = SC_MEMERROR;
			return(FALSE);
			}
		negate((LPTR)lpColorMap->RGBData, sizeof(RGBS)*lpColorMap->NumEntries);
		lpParms->Common.StatusCode = ApplyColorMap(lpImage, lpColorMap, FALSE, DT_NONE, lpParms->Common.idDirty);
		FrameDestroyColorMap(lpColorMap);
		if (lpParms->Common.StatusCode == SC_SUCCESS)
			lpParms->Common.UpdateType = UT_DATATYPE;
	}
	else
	{
		SetEngineDef(&Engine);
		Engine.lpDataProc = invert_proc;
		lpParms->Common.StatusCode = LineEngineSelObj(lpImage,&Engine,lpParms->Common.idDirty);
		if (!AstralIsRectEmpty(&Engine.rUpdate))
		{
			lpParms->Common.UpdateType = UT_AREA;
			lpParms->Common.rUpdateArea = Engine.rUpdate;
		}
	}
	return(lpParms->Common.StatusCode == SC_SUCCESS);
}
Exemplo n.º 2
0
LOCAL STATUS_CODE ApplyMaps(LPIMAGE lpImage, LPMAPS lpMaps, ITEMID idDirty,
						LPRECT lpUpdateRect, LPUPDATE_TYPE lpUpdateType)
/************************************************************************/
{
	ENGINE Engine;
	FRMTYPEINFO TypeInfo;
	LPCOLORMAP lpColorMap;
	STATUS_CODE StatusCode;

	AstralSetRectEmpty(lpUpdateRect);
	*lpUpdateType = UT_NONE;
	ImgGetTypeInfo(lpImage, &TypeInfo);
	if (TypeInfo.DataType == FDT_PALETTECOLOR)
	{
		lpColorMap = FrameCopyColorMap(TypeInfo.ColorMap);
		if (!lpColorMap)
		{
			Message(IDS_EMEMALLOC);
			return(SC_MEMERROR);
		}
		ApplyMaps24((LPTR)lpColorMap->RGBData, lpColorMap->NumEntries, lpMaps);
		StatusCode = ApplyColorMap(lpImage, lpColorMap, FALSE, DT_NONE, idDirty);
		FrameDestroyColorMap(lpColorMap);
		if (StatusCode == SC_SUCCESS)
			*lpUpdateType = UT_DATATYPE;
	}
	else
	{
		SetEngineDef(&Engine);
		Engine.lpDataProc = (LPDATAPROC)ApplyMapsProc;
		Engine.lpParam = lpMaps;
		StatusCode = LineEngineSelObj(lpImage, &Engine, idDirty);
		if (!AstralIsRectEmpty(&Engine.rUpdate))
		{
			*lpUpdateRect = Engine.rUpdate;
			*lpUpdateType = UT_AREA;
		}
	}
	return(StatusCode);
}
Exemplo n.º 3
0
//************************************************************************
LOCAL STATUS_CODE ApplyCalibration(
	LPIMAGE		lpImage,
	ITEMID      dirty,
	LPSTR       lpScanMap,
	LPSTR       lpPrintMap,
	LPRECT		lpUpdateRect,
	LPUPDATE_TYPE lpUpdateType)
//************************************************************************
{
	FNAME  szFileName;
	ENGINE Engine;
	LPCALMAPS lpMaps;
	BOOL fScanMap, fPrintMap;
	FRMTYPEINFO TypeInfo;
	LPCOLORMAP lpColorMap;
	STATUS_CODE StatusCode;
	int i;
	
	ASSERT(lpImage);

	AstralSetRectEmpty(lpUpdateRect);
	*lpUpdateType = UT_NONE;

	ImgGetTypeInfo(lpImage, &TypeInfo);
	lpMaps = (LPCALMAPS)Alloc(sizeof(CALMAPS));
	if (!lpMaps)
	{
		Message(IDS_EMEMALLOC);
		return(SC_MEMERROR);
	}
	for (i = 0; i < CALSCAN_MAPS; ++i)
		ResetMap( &lpMaps->ScanMap[i], CALPOINTS, NO );

	if (fScanMap = (lstrlen(lpScanMap) != 0))
	{
		if ( LookupExtFileN( lpScanMap, szFileName, IDN_SCANMAP, NO ) )
		{
			// Remember that the maps load in XRGB order
			if (!LoadMap( 	&lpMaps->ScanMap[CALSCAN_GRAY],
							&lpMaps->ScanMap[CALSCAN_RED],
							&lpMaps->ScanMap[CALSCAN_GREEN],
							&lpMaps->ScanMap[CALSCAN_BLUE],
							szFileName ))
			{
				FreeUp(lpMaps);
				return(SC_READERROR);
			}
			if (TypeInfo.DataType == FDT_CMYKCOLOR)
			{
				// make maps work on cmyk
				for (i = 0; i < CALSCAN_MAPS; ++i)
					ReverseMap(&lpMaps->ScanMap[i], FALSE);
			}
		}
		else
		{
			fScanMap = NO;
		}
	}

	for (i = 0; i < CAL_MAPS; ++i)
		ResetMap( &lpMaps->PrintMap[i], CALPOINTS, NO );
	if (fPrintMap = (lstrlen(lpPrintMap) != 0))
	{
		if ( LookupExtFileN( lpPrintMap, szFileName, IDN_CALMAP, NO ) )
		{
			// Remember that the maps load in MCMYK order
			if (!LoadCalMap(	&lpMaps->PrintMap[CAL_MASTER],
								&lpMaps->PrintMap[CAL_CYAN],
								&lpMaps->PrintMap[CAL_MAGENTA],
								&lpMaps->PrintMap[CAL_YELLOW],
								&lpMaps->PrintMap[CAL_BLACK],
								szFileName ))
			{
				FreeUp(lpMaps);
				return(SC_READERROR);
			}
			if (TypeInfo.DataType != FDT_CMYKCOLOR)
			{
				// make maps work on rgb
				for (i = 0; i < CAL_MAPS; ++i)
					ReverseMap(&lpMaps->PrintMap[i], FALSE);
			}
		}
		else
		{
			fPrintMap = NO;
			lpPrintMap = NULL;
		}
	}

	if (!fScanMap && !fPrintMap)
	{
		FreeUp(lpMaps);
		return(SC_SUCCESS); // user selected no maps??? 
	}

	switch (TypeInfo.DataType)
	{
		case FDT_LINEART:
		case FDT_GRAYSCALE:
			MakeFloatMap(&lpMaps->ScanMap[CALSCAN_GRAY], lpMaps->CalPnts);
			MakeFloatMap(&lpMaps->PrintMap[CAL_BLACK], lpMaps->TmpPnts);
			MapCombine(lpMaps->CalPnts, lpMaps->TmpPnts);
			MapCreateLut(lpMaps->CalPnts, lpMaps->Lut[0]);
		break;

		case FDT_CMYKCOLOR:
			for (i = 0; i < 4; ++i)
			{
				if (i == 3) // black
					MakeFloatMap(&lpMaps->ScanMap[CALSCAN_GRAY], lpMaps->CalPnts);
				else
					MakeFloatMap(&lpMaps->ScanMap[CALSCAN_RED+i], lpMaps->CalPnts);
				MakeFloatMap(&lpMaps->PrintMap[CAL_MASTER], lpMaps->TmpPnts);
				MapCombine(lpMaps->CalPnts, lpMaps->TmpPnts);
				MakeFloatMap(&lpMaps->PrintMap[CAL_CYAN+i], lpMaps->TmpPnts);
				MapCombine(lpMaps->CalPnts, lpMaps->TmpPnts);
				MapCreateLut(lpMaps->CalPnts, lpMaps->Lut[i]);
			}
		break;

		default:
		case FDT_RGBCOLOR:
		case FDT_PALETTECOLOR:
			for (i = 0; i < 3; ++i)
			{
				MakeFloatMap(&lpMaps->ScanMap[CALSCAN_RED+i], lpMaps->CalPnts);
				MakeFloatMap(&lpMaps->PrintMap[CAL_MASTER], lpMaps->TmpPnts);
				MapCombine(lpMaps->CalPnts, lpMaps->TmpPnts);
				MakeFloatMap(&lpMaps->PrintMap[CAL_CYAN+i], lpMaps->TmpPnts);
				MapCombine(lpMaps->CalPnts, lpMaps->TmpPnts);
				MapCreateLut(lpMaps->CalPnts, lpMaps->Lut[i]);
			}
		break;
	}


	ImgGetTypeInfo(lpImage, &TypeInfo);
	if (TypeInfo.DataType == FDT_PALETTECOLOR)
	{
		lpColorMap = FrameCopyColorMap(TypeInfo.ColorMap);
		if (!lpColorMap)
		{
			Message(IDS_EMEMALLOC);
			return(SC_MEMERROR);
		}
		LineCalMapProc(0, 0, lpColorMap->NumEntries-1,
							(LPTR)lpColorMap->RGBData,
							(LPTR)lpColorMap->RGBData,
							3,
							lpMaps);
		StatusCode = ApplyColorMap(lpImage, lpColorMap, FALSE, DT_NONE, dirty);
		FrameDestroyColorMap(lpColorMap);
		if (StatusCode == SC_SUCCESS)
			*lpUpdateType = UT_DATATYPE;
	}
	else
	{
		SetEngineDef(&Engine);
		Engine.lpDataProc = (LPDATAPROC)LineCalMapProc;

		Engine.lpParam = lpMaps;
		StatusCode = LineEngineSelObj(lpImage, &Engine, dirty);
		if (!AstralIsRectEmpty(&Engine.rUpdate))
		{
			*lpUpdateRect = Engine.rUpdate;
			*lpUpdateType = UT_AREA;
		}
	}
	FreeUp(lpMaps);
	return(StatusCode);
}