示例#1
0
static void Check2(int aValue, int aExpected, int aLine)
	{
	if(aValue != aExpected)
		{
		if(TheDb2)
			{
			const char* errmsg = sqlite3_errmsg(TheDb2);
			PrintS("*** SQLITE error message: %s\r\n", errmsg);
			}
		TestCleanup();
		PrintIII("*** Test check failed! Line=%d. Expected error: %d, got: %d\r\n", aLine, aExpected, aValue);
		TestAbort(aLine);
		}
	}
示例#2
0
static void Check1(int aValue, int aLine)
	{
	if(!aValue)
		{
		if(TheDb2)
			{
			const char* errmsg = sqlite3_errmsg(TheDb2);
			PrintS("*** SQLITE error message: %s\r\n", errmsg);
			}
		TestCleanup();
		PrintI("*** Test check failed! Line=%d\r\n", aLine);
		TestAbort(aLine);
		}
	}
示例#3
0
static void Check1(int aValue, int aLine)
	{
	if(!aValue)
		{
		if(TheDb)
			{
			const char* errmsg = sqlite3_errmsg(TheDb);
			PrintS("*** DB1: SQLITE error message: %s\r\n", errmsg);
			}
		if(TheDb2)
			{
			const char* errmsg = sqlite3_errmsg(TheDb2);
			PrintS("*** DB2: SQLITE error message: %s\r\n", errmsg);
			}
		PrintI("*** Test check failed! Line=%d\r\n", aLine);
		TestEnvDestroy();
		TestAbort(aLine);
		}
	}
示例#4
0
static void Check64(sqlite_int64 aValue, sqlite_int64 aExpected, int aLine)
	{
	if(aValue != aExpected)
		{
		if(TheDb)
			{
			const char* errmsg = sqlite3_errmsg(TheDb);
			PrintS("*** DB1: SQLITE error message: %s\r\n", errmsg);
			}
		if(TheDb2)
			{
			const char* errmsg = sqlite3_errmsg(TheDb2);
			PrintS("*** DB2: SQLITE error message: %s\r\n", errmsg);
			}
		PrintII64I64("*** Test check failed! Line=%ld. Expected error: %ld, got: %d\r\n", aLine, aExpected, aValue);
		TestEnvDestroy();
		TestAbort(aLine);
		}
	}
示例#5
0
static void ApplyChannel (GPtr globals,
						  ReadChannelDesc *source,
						  PixelMemoryDesc *sDesc,
						  ReadChannelDesc *mask, 
						  PixelMemoryDesc *mDesc,
						  WriteChannelDesc *dest, 
						  ChannelReadPort destRead,
						  PixelMemoryDesc *dDesc,
						  PixelMemoryDesc *rDesc,
						  size_t *done,
						  size_t total)
	{
	
	VRect limit;
	int32 row, col, row2, col2;
	unsigned8 *s, *m, *d;
	unsigned8 *r = (unsigned8 *)rDesc->data;
	Boolean initRandom = (*r == kInitRandom);
		
	limit = source->bounds;
	TrimVRect (&limit, &dest->bounds);
	if (mask != NULL) TrimVRect (&limit, &mask->bounds);
		
	if (limit.right <= limit.left || limit.bottom <= limit.top) return;
	
	for (row = limit.top; row < limit.bottom; row += kBlockRows)
		for (col = limit.left; col < limit.right; col += kBlockCols)
			{
			
			VRect area;
			PSScaling scaling;
			VRect wrote;
			
			if (TestAbort ())
				{
				gResult = userCanceledErr;
				return;
				}
			
			area.top = row;  area.bottom = row + kBlockRows;
			area.left = col; area.right  = col + kBlockCols;
			
			if (limit.bottom < area.bottom) area.bottom = limit.bottom;
			if (limit.right  < area.right ) area.right  = limit.right;
			
			scaling.sourceRect = area;
			scaling.destinationRect = area;
			
			gResult = ReadPixels (destRead, &scaling, &area, dDesc, &wrote);
			if (gResult != noErr) return;
			
			if (!EqualVRects (&area, &wrote))
				{
				gResult = -1;
				return;
				}
				
			gResult = ReadPixels (source->port, &scaling, &area, sDesc, &wrote);
			if (gResult != noErr) return;
			
			if (!EqualVRects (&area, &wrote))
				{
				gResult = -1;
				return;
				}
				
			if (mask != NULL)
				{
				
				gResult = ReadPixels (mask->port, &scaling, &area, mDesc, &wrote);
				if (gResult != noErr) return;
				
				if (!EqualVRects (&area, &wrote))
					{
					gResult = -1;
					return;
					}
				}
				m = (unsigned8 *) mDesc->data;
				/* mask all set and ready to go */
									
			/* heart of the routine.  Compares source pixel and destination
			   pixel and, if destination is smaller, replaces it with
			   source */

			s = (unsigned8 *) sDesc->data;
			d = (unsigned8 *) dDesc->data;
			r = (unsigned8 *) rDesc->data;
						
			for (row2 = kBlockRows; row2 > 0; --row2)
				for (col2 = kBlockCols; col2 > 0; --col2)
				{
					
					switch (gWhatArea)
					{
						case iSelectMin:
							if (mask != NULL && *m < *s ) *s = *m;
							if (*s > 127) *d = *s;
							else *d = 0;
							break;
						case iSelectMax:
							if (mask != NULL && *m < *s ) *s = *m;
							if (*s < 128) *d = 255 - *s; // if (*d < *s) *d = *s;
							else *d = 0;
							break;
						case iSelectRandom:
							if (initRandom)
							{
								if ((((unsigned16) rand ()) % 100) < gPercent)
									*r = kRandomOn; // flag as picked
								else *r = kRandomOff; // flag as off
							}
							if (*r == kRandomOn)
								*d = 255;
							else *d = 0;
							break;
					}
					++s;
					++d;
					++r;
					if (mask != NULL) ++m;
				}
					
			gResult = WritePixels (dest->port, &area, dDesc);
			if (gResult != noErr) return;
			
			*done += (area.right - area.left) * (area.bottom - area.top);
			
			PIUpdateProgress ((int32)*done, (int32)total);
				
			}
	
	}