Пример #1
0
void TPack_ExtractSelected(TPack_WindowData * pData)
{
	HWND            hLB = GetDlgItem(pData->hwnd, IDC_TEXTURELIST);
	int             nSel;
	BitmapEntry *	pEntry;
	char            szName[MAX_TEXTURE_NAME_LENGTH];
	char            szFile[MAX_PATH];
	char            szPath[MAX_PATH];
	int             nErrorCode;

	//----------------------------------------------
	// Get current selected list box entry.
	// Get the  geBitmap.
	// Write 8-bit BMP file.
	//----------------------------------------------

	// Ouput to the current directory
	GetCurrentDirectory(MAX_PATH, szPath);

	nSel = ListBox_GetCurSel(hLB);
	if (nSel != LB_ERR)

	if (ListBox_GetText(hLB, nSel, szName) != LB_ERR)
	{
		pEntry = FindBitmap(pData, szName);
		if (pEntry)
		{
			// Create an output file name
			strcpy(szFile, szPath);
			strcat(szFile, "\\");
			strcat(szFile, pEntry->Name);
			strcat(szFile, ".bmp");

			nErrorCode = WriteBMP8(szFile, pEntry->Bitmap);

			if (nErrorCode != TPACKERROR_OK)
			{
				// Error writing this bitmap
				switch (nErrorCode)
				{
					case TPACKERROR_CREATEFILE:
						NonFatalError("Unable to create output file %s", szFile);
						break;
					case TPACKERROR_WRITE:
						NonFatalError("I/O error writing %s", szFile);
						break;
					case TPACKERROR_MEMORYALLOCATION:
						NonFatalError("Memory allocation error writing %s", szFile);
						break;
					case TPACKERROR_UNKNOWN:
					default:
						NonFatalError("UInknown error writing %s", szFile);
				}
			}
		}
	}
}
Пример #2
0
int main(int argc, char *argv[]) {
	UINT8 *img,*p;
	INT xres, yres;
	char line[30];
	FILE *f;
	int r,g,b;
	int x,y;
	
	int n;
	char file[30];
	int frame;
	
	if (argc < 2) {
		printf("usage : vdp2bmp file\n");
		return 1;
	}
	xres = 690;
	yres = 270;

	f = fopen(argv[1], "r");
	if (f == NULL) {
		printf("can't open file\n");
		return 1;
	}
	
	img = (UINT8 *)calloc(xres * yres * 3, sizeof(UINT8));
	p = img;
	frame = 0;
	x = -1; y = -1;
	while(!feof(f)) {
		fgets(line, 30, f);
		
		if (strlen(line) >= 3) {
			if ( (line[0] == '#') && (line[1] == 'H') ) {
				if (x >= 0) {
					y++;
					x = -1;
				}
			} else if ( (line[0] == '#') && (line[1] == 'V') ) {
				if (y >= 0) {
					y = -1;
					x = -1;
					sprintf(file,"vid%05d.bmp", frame);
					WriteBMP8(file, img, xres, yres );	
					memset(img, 0, xres * yres * 3);
					frame++;
				}
			} else if (sscanf(line, "%1x%1x%1x", &r, &g, &b) == 3) {
				if (x < 0) x = 0;
				if (y < 0) y = 0;
				p = img + (xres * y * 3) + (x * 3);
				r = (r<<4) | (r<<1);
				g = (g<<4) | (g<<1);
				b = (b<<4) | (b<<1);
				*p++ = b;
				*p++ = g;
				*p++ = r;
				x++;
			}
		}
		
	}	
	fclose(f);

	if (y >= 0) {
		sprintf(file,"vid%05d.bmp", frame);
		WriteBMP8(file, img, xres, yres );
	}
	return 0;
}
Пример #3
0
void TPack_ExtractAll(TPack_WindowData * pData)
{
	HWND            hLB = GetDlgItem(pData->hwnd, IDC_TEXTURELIST);
	int             nCount;
	int             i;
	BitmapEntry *	pEntry;
	char            szName[MAX_TEXTURE_NAME_LENGTH];
	char            szFile[MAX_PATH];
	char            szPath[MAX_PATH];
	int             nErrorCode;
	HCURSOR         hCursor;

	//----------------------------------------------
	// Travese list box.
	// For each list box entry.
	//    Get the  geBitmap
	//    Write 8-bit BMP file.
	//----------------------------------------------

	// This may take a while, let them know something is happening
	// NOTE: Ideally a progress bar is needed.
	hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
	ShowCursor(FALSE);
	ShowCursor(TRUE);


	// Ouput to the current directory
	GetCurrentDirectory(MAX_PATH, szPath);

	nCount = ListBox_GetCount(hLB);

	for (i = 0; i < nCount; i++)
	{
		if (ListBox_GetText(hLB, i, szName) != LB_ERR)
		{
			pEntry = FindBitmap(pData, szName);
			if (pEntry)
			{
				strcpy(szFile, szPath);
				strcat(szFile, "\\");
				strcat(szFile, pEntry->Name);
				strcat(szFile, ".bmp");

				nErrorCode = WriteBMP8(szFile, pEntry->Bitmap);

				if (nErrorCode != TPACKERROR_OK)
				{
					// Error writing this bitmap
					switch (nErrorCode)
					{
						case TPACKERROR_CREATEFILE:
							NonFatalError("Unable to create output file %s", szFile);
							break;
						case TPACKERROR_WRITE:
							NonFatalError("I/O error writing %s", szFile);
							break;
						case TPACKERROR_MEMORYALLOCATION:
							NonFatalError("Memory allocation error writing %s", szFile);
							break;
						case TPACKERROR_UNKNOWN:
						default:
							NonFatalError("UInknown error writing %s", szFile);
					}

					// Exit extract all loop on error
					break;
				}
			}
		}
	}

	// Restore the cursor
	SetCursor(hCursor);

}