⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugintarga.cpp

📁 这是VCF框架的代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
									}								}							}					done2 :							break;						}						default :							freeimage.free_proc(dib);							return NULL;					}					break;				}				case 24 :				{					dib = freeimage.allocate_proc(header.is_width, header.is_height, 24, 0xFF, 0xFF00, 0xFF0000);					if (dib == 0)						throw "DIB allocation failed";										// read in the bitmap bits					switch (header.image_type) {						case 2 :						{							if (fliphoriz)								for (unsigned count = header.is_height; count > 0; count--) {									BYTE *bits = bits = Internal_GetScanLine(freeimage, dib, count-1, flipvert);									io.read_proc(bits, line, 1, handle);									bits += pitch;								}							else								for (unsigned count = 0; count < header.is_height; count++) {									BYTE *bits = bits = Internal_GetScanLine(freeimage, dib, count, flipvert);									io.read_proc(bits, line, 1, handle);									bits += pitch;								}							break;						}						case 10 :						{							int x = 0;							int y = 0;							BYTE rle;							BYTE *bits;														if(fliphoriz)								bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);							else								bits = Internal_GetScanLine(freeimage, dib, y, flipvert);														if (alphabits) {								while(1) {									io.read_proc(&rle,1, 1, handle);																		if (rle>127) {										rle -= 127;										BGRAQUAD quad;										io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle);										for (int ix = 0; ix < rle; ix++) {											bits[x++] = quad.bgraBlue;											bits[x++] = quad.bgraGreen;											bits[x++] = quad.bgraRed;											bits[x++] = quad.bgraAlpha;											if (x >= line) {												x = 0;												y++;												if (y >= header.is_height)													goto done243;												if(fliphoriz)													bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);												else													bits = Internal_GetScanLine(freeimage, dib, y, flipvert);											}										}									} else {										rle++;										for (int ix = 0; ix < rle; ix++) {											BGRAQUAD quad;											io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle);											bits[x++] = quad.bgraBlue;											bits[x++] = quad.bgraGreen;											bits[x++] = quad.bgraRed;											bits[x++] = quad.bgraAlpha;																						if (x >= line) {												x = 0;												y++;												if (y >= header.is_height)													goto done243;																							if(fliphoriz)													bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);												else													bits = Internal_GetScanLine(freeimage, dib, y, flipvert);											}										}									}								}							} else {								while (1) {									io.read_proc(&rle,1, 1, handle);																		if (rle>127) {										rle -= 127;										RGBTRIPLE triple;										io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle);										for (int ix = 0; ix < rle; ix++) {											bits[x++] = triple.rgbtBlue;											bits[x++] = triple.rgbtGreen;											bits[x++] = triple.rgbtRed;											if (x >= line) {												x = 0;												y++;												if (y >= header.is_height)													goto done243;																																			if(fliphoriz)													bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);												else													bits = Internal_GetScanLine(freeimage, dib, y, flipvert);											}										}									} else {										rle++;										for (int ix = 0; ix < rle; ix++) {											RGBTRIPLE triple;													io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle);											bits[x++] = triple.rgbtBlue;											bits[x++] = triple.rgbtGreen;											bits[x++] = triple.rgbtRed;																						if (x >= line) {												x = 0;												y++;												if (y >= header.is_height)													goto done243;																							if(fliphoriz)													bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);												else													bits = Internal_GetScanLine(freeimage, dib, y, flipvert);											}										}									}								}							}					done243 :							break;						}						default :							freeimage.free_proc(dib);							return NULL;					}					break;				}								case 32 :				{					int pixel_bits;					if (TARGA_LOAD_RGB888 & flags) {						pixel_bits = 24;						line = CalculateLine(header.is_width, pixel_bits);						pitch = CalculatePitch(line);					} else {						pixel_bits = 32;					}					const unsigned pixel_size = unsigned (pixel_bits) / 8;					// Allocate the DIB					dib = freeimage.allocate_proc(header.is_width, header.is_height, pixel_bits, 0xFF, 0xFF00, 0xFF0000);										if (dib == 0)						throw "DIB allocation failed";										// read in the bitmap bits					switch (header.image_type) {						case 2 :						{							// uncompressed							if (alphabits) {								if (fliphoriz)									for (unsigned count = header.is_height; count > 0; count--) {										BYTE *bits = bits = Internal_GetScanLine(freeimage, dib, count-1, flipvert);										for (unsigned cols = 0; cols < header.is_width; cols++) {											RGBQUAD rgb;											io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle);											bits[0] = rgb.rgbBlue;											bits[1] = rgb.rgbGreen;											bits[2] = rgb.rgbRed;											if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888)												bits[3] = rgb.rgbReserved;																						bits += pixel_size;										}									}								else									for (unsigned count = 0; count < header.is_height; count++) {										BYTE *bits = Internal_GetScanLine(freeimage, dib, count, flipvert);										for (unsigned cols = 0; cols < header.is_width; cols++) {											RGBQUAD rgb;											io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle);											bits[0] = rgb.rgbBlue;											bits[1] = rgb.rgbGreen;											bits[2] = rgb.rgbRed;											if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888)												bits[3] = rgb.rgbReserved;																						bits += pixel_size;										}									}							} else {								if (fliphoriz)									for (unsigned count = header.is_height; count > 0; count--) {										BYTE *bits;										if (fliphoriz)											bits = Internal_GetScanLine(freeimage, dib, header.is_height-count, flipvert);										else											bits = Internal_GetScanLine(freeimage, dib, count-1, flipvert);										for (unsigned cols = 0; cols < header.is_width; cols++) {											RGBQUAD rgb;											io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle);											bits[0] = rgb.rgbBlue;											bits[1] = rgb.rgbGreen;											bits[2] = rgb.rgbRed;											if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888)												bits[3] = rgb.rgbReserved;																						bits += pixel_size;										}									}								else									for (unsigned count = 0; count < header.is_height; count++) {										BYTE *bits;										if(fliphoriz)											bits = Internal_GetScanLine(freeimage, dib, header.is_height-count-1, flipvert);										else											bits = Internal_GetScanLine(freeimage, dib, count, flipvert);										for (unsigned cols = 0; cols < header.is_width; cols++) {											RGBQUAD rgb;											io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle);											bits[0] = rgb.rgbBlue;											bits[1] = rgb.rgbGreen;											bits[2] = rgb.rgbRed;											if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888)												bits[3] = rgb.rgbReserved;																						bits += pixel_size;										}									}							}							break;						}						case 10:						{							int x = 0;							int y = 0;							BYTE rle;							BYTE *bits;														if(fliphoriz)								bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);							else								bits = Internal_GetScanLine(freeimage, dib, y, flipvert);														while(1) {								io.read_proc(&rle,1, 1, handle);																	if (rle>127) {									rle -= 127;									BGRAQUAD quad;									io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle);									for (int ix = 0; ix < rle; ix++) {										bits[x++] = quad.bgraBlue;										bits[x++] = quad.bgraGreen;										bits[x++] = quad.bgraRed;										bits[x++] = quad.bgraAlpha;										if (x >= line) {											x = 0;											y++;											if (y >= header.is_height)												goto done3210;											if(fliphoriz)												bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);											else												bits = Internal_GetScanLine(freeimage, dib, y, flipvert);										}									}								} else {										rle++;									for (int ix = 0; ix < rle; ix++) {										BGRAQUAD quad;										io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle);										bits[x++] = quad.bgraBlue;										bits[x++] = quad.bgraGreen;										bits[x++] = quad.bgraRed;										bits[x++] = quad.bgraAlpha;																					if (x >= line) {											x = 0;											y++;											if (y >= header.is_height)												goto done3210;																						if(fliphoriz)												bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert);											else												bits = Internal_GetScanLine(freeimage, dib, y, flipvert);										}									}								}							}					done3210 :							break;						}						default :							freeimage.free_proc(dib);							return NULL;					}					break;				}			}			return (FIBITMAP *)dib;		} catch(char *message) {			freeimage.output_message_proc(s_format_id, message);			return NULL;		}	}	return NULL;}// ==========================================================//   Init// ==========================================================void DLL_CALLCONVInitTARGA(Plugin &plugin, int format_id) {	s_format_id = format_id;	plugin.format_proc = Format;	plugin.description_proc = Description;	plugin.extension_proc = Extension;	plugin.regexpr_proc = RegExpr;	plugin.load_proc = Load;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -