// ----------------------------------------------------------------------------- void vDeviceConfigThreshold (void) { vPrintStr_P (PSTR("\n---Reglage Seuils\n")); vDevicePrintThreshold (); vPrintStr_P (PSTR("Seuil 0L [0-127] ? ")); vWDevSetThresholdLow (iGetInt (4)); vNewLine (); vPrintStr_P (PSTR("Seuil 1L [0-127] ? ")); vWDevSetThresholdHigh (iGetInt (4)); vNewLine (); }
// ----------------------------------------------------------------------------- void vDeviceConfigSyncount (void) { vPrintStr_P (PSTR("\n---Reglage Synthe Lock Count\n")); vDevicePrintSyncount (); vPrintStr_P (PSTR("Count [0-255] ? ")); vWDevSetSynthLockCount (iGetInt (4)); vNewLine (); }
// ----------------------------------------------------------------------------- void vDeviceConfigPaBias (void) { vPrintStr_P (PSTR("\n---Reglage Puissance\n")); vDevicePrintPaBias (); vPrintStr_P (PSTR("PA Bias ? ")); vWDevSetPaBias (iGetInt (2)); vNewLine (); }
// ----------------------------------------------------------------------------- void vDeviceConfigChannel (void) { vPrintStr_P (PSTR("\n---Reglage Canal\n")); vDevicePrintChannel (); vPrintStr_P (PSTR("Canal ? ")); vWDevSetChannel (iGetInt (3)); vNewLine (); }
ILboolean iSaveJpegInternal() { struct jpeg_compress_struct JpegInfo; struct jpeg_error_mgr Error; JSAMPROW row_pointer[1]; ILimage *TempImage; ILubyte *TempData; ILenum Type = 0; if (iCurImage == NULL) { ilSetError(IL_ILLEGAL_OPERATION); return IL_FALSE; } /*if (iGetHint(IL_COMPRESSION_HINT) == IL_USE_COMPRESSION) Quality = 85; // Not sure how low we should dare go... else Quality = 99;*/ // angua: RGB images also need to be converted to RGBA if ((iCurImage->Format != IL_RGBA && iCurImage->Format != IL_LUMINANCE) || iCurImage->Bpc != 1) { // taaaki: since RGB_PIXELSIZE was changed to 4, the conversion to // RGB is short one colour component, causing screenshots to crash TempImage = iConvertImage(iCurImage, IL_RGBA, IL_UNSIGNED_BYTE); if (TempImage == NULL) { return IL_FALSE; } } else { TempImage = iCurImage; } if (TempImage->Origin == IL_ORIGIN_LOWER_LEFT) { TempData = iGetFlipped(TempImage); if (TempData == NULL) { if (TempImage != iCurImage) ilCloseImage(TempImage); return IL_FALSE; } } else { TempData = TempImage->Data; } JpegInfo.err = jpeg_std_error(&Error); // Now we can initialize the JPEG compression object. jpeg_create_compress(&JpegInfo); //jpeg_stdio_dest(&JpegInfo, JpegFile); devil_jpeg_write_init(&JpegInfo); JpegInfo.image_width = TempImage->Width; // image width and height, in pixels JpegInfo.image_height = TempImage->Height; JpegInfo.input_components = TempImage->Bpp; // # of color components per pixel // John Villar's addition if (TempImage->Bpp == 1) JpegInfo.in_color_space = JCS_GRAYSCALE; else JpegInfo.in_color_space = JCS_RGB; jpeg_set_defaults(&JpegInfo); /*#ifndef IL_USE_JPEGLIB_UNMODIFIED Type = iGetInt(IL_JPG_SAVE_FORMAT); if (Type == IL_EXIF) { JpegInfo.write_JFIF_header = FALSE; JpegInfo.write_EXIF_header = TRUE; } else if (Type == IL_JFIF) { JpegInfo.write_JFIF_header = TRUE; JpegInfo.write_EXIF_header = FALSE; } EXIF not present int libjpeg... #else*/ Type = Type; JpegInfo.write_JFIF_header = TRUE; //#endif//IL_USE_JPEGLIB_UNMODIFIED jpeg_set_quality(&JpegInfo, iGetInt(IL_JPG_QUALITY), IL_TRUE); jpeg_start_compress(&JpegInfo, IL_TRUE); //row_stride = image_width * 3; // JSAMPLEs per row in image_buffer while (JpegInfo.next_scanline < JpegInfo.image_height) { // jpeg_write_scanlines expects an array of pointers to scanlines. // Here the array is only one element long, but you could pass // more than one scanline at a time if that's more convenient. row_pointer[0] = &TempData[JpegInfo.next_scanline * TempImage->Bps]; (void) jpeg_write_scanlines(&JpegInfo, row_pointer, 1); } // Step 6: Finish compression jpeg_finish_compress(&JpegInfo); // Step 7: release JPEG compression object // This is an important step since it will release a good deal of memory. jpeg_destroy_compress(&JpegInfo); if (TempImage->Origin == IL_ORIGIN_LOWER_LEFT) ifree(TempData); if (TempImage != iCurImage) ilCloseImage(TempImage); return IL_TRUE; }
ILboolean iLoadPcdInternal() { ILubyte VertOrientation; ILuint Width, Height, i, Total, x, CurPos = 0; ILubyte *Y1=NULL, *Y2=NULL, *CbCr=NULL, r = 0, g = 0, b = 0; ILuint PicNum; if (iCurImage == NULL) { ilSetError(IL_ILLEGAL_OPERATION); return IL_FALSE; } iseek(72, IL_SEEK_CUR); if (iread(&VertOrientation, 1, 1) != 1) return IL_FALSE; iseek(-72, IL_SEEK_CUR); // Can't rewind PicNum = iGetInt(IL_PCD_PICNUM); switch (PicNum) { case 0: iseek(0x02000, IL_SEEK_CUR); Width = 192; Height = 128; break; case 1: iseek(0x0b800, IL_SEEK_CUR); Width = 384; Height = 256; break; case 2: iseek(0x30000, IL_SEEK_CUR); Width = 768; Height = 512; break; default: ilSetError(IL_INVALID_PARAM); return IL_FALSE; } if (itell() == IL_EOF) // Supposed to have data here. return IL_FALSE; Y1 = (ILubyte*)ialloc(Width); Y2 = (ILubyte*)ialloc(Width); CbCr = (ILubyte*)ialloc(Width); if (Y1 == NULL || Y2 == NULL || CbCr == NULL) { ifree(Y1); ifree(Y2); ifree(CbCr); return IL_FALSE; } if (!ilTexImage(Width, Height, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, NULL)) { return IL_FALSE; } iCurImage->Origin = IL_ORIGIN_LOWER_LEFT; Total = Height >> 1; for (i = 0; i < Total; i++) { iread(Y1, 1, Width); iread(Y2, 1, Width); if (iread(CbCr, 1, Width) != Width) { // Only really need to check the last one. ifree(Y1); ifree(Y2); ifree(CbCr); return IL_FALSE; } for (x = 0; x < Width; x++) { YCbCr2RGB(Y1[x], CbCr[x / 2], CbCr[(Width / 2) + (x / 2)], &r, &g, &b); iCurImage->Data[CurPos++] = r; iCurImage->Data[CurPos++] = g; iCurImage->Data[CurPos++] = b; } for (x = 0; x < Width; x++) { YCbCr2RGB(Y2[x], CbCr[x / 2], CbCr[(Width / 2) + (x / 2)], &r, &g, &b); iCurImage->Data[CurPos++] = r; iCurImage->Data[CurPos++] = g; iCurImage->Data[CurPos++] = b; } } ifree(Y1); ifree(Y2); ifree(CbCr); // Not sure how it is...the documentation is hard to understand if ((VertOrientation & 0x3F) != 8) iCurImage->Origin = IL_ORIGIN_LOWER_LEFT; else iCurImage->Origin = IL_ORIGIN_UPPER_LEFT; return ilFixImage(); }
// Internal function used to save the Sgi. ILboolean iSaveSgiInternal() { ILuint i, c; ILboolean Compress; ILimage *Temp = iCurImage; ILubyte *TempData; if (iCurImage == NULL) { ilSetError(IL_ILLEGAL_OPERATION); return IL_FALSE; } if (iCurImage->Format != IL_LUMINANCE //while the sgi spec doesn't directly forbid rgb files with 2 //channels, they are quite uncommon and most apps don't support //them. so convert lum_a images to rgba before writing. //&& iCurImage->Format != IL_LUMINANCE_ALPHA && iCurImage->Format != IL_RGB && iCurImage->Format != IL_RGBA) { if (iCurImage->Format == IL_BGRA || iCurImage->Format == IL_LUMINANCE_ALPHA) Temp = iConvertImage(iCurImage, IL_RGBA, DetermineSgiType(iCurImage->Type)); else Temp = iConvertImage(iCurImage, IL_RGB, DetermineSgiType(iCurImage->Type)); } else if (iCurImage->Type > IL_UNSIGNED_SHORT) { Temp = iConvertImage(iCurImage, iCurImage->Format, DetermineSgiType(iCurImage->Type)); } //compression of images with 2 bytes per channel doesn't work yet Compress = iGetInt(IL_SGI_RLE) && Temp->Bpc == 1; if (Temp == NULL) return IL_FALSE; SaveBigUShort(SGI_MAGICNUM); // 'Magic' number if (Compress) iputc(1); else iputc(0); if (Temp->Type == IL_UNSIGNED_BYTE) iputc(1); else if (Temp->Type == IL_UNSIGNED_SHORT) iputc(2); // Need to error here if not one of the two... if (Temp->Format == IL_LUMINANCE || Temp->Format == IL_COLOUR_INDEX) SaveBigUShort(2); else SaveBigUShort(3); SaveBigUShort((ILushort)Temp->Width); SaveBigUShort((ILushort)Temp->Height); SaveBigUShort((ILushort)Temp->Bpp); switch (Temp->Type) { case IL_BYTE: SaveBigInt(SCHAR_MIN); // Minimum pixel value SaveBigInt(SCHAR_MAX); // Maximum pixel value break; case IL_UNSIGNED_BYTE: SaveBigInt(0); // Minimum pixel value SaveBigInt(UCHAR_MAX); // Maximum pixel value break; case IL_SHORT: SaveBigInt(SHRT_MIN); // Minimum pixel value SaveBigInt(SHRT_MAX); // Maximum pixel value break; case IL_UNSIGNED_SHORT: SaveBigInt(0); // Minimum pixel value SaveBigInt(USHRT_MAX); // Maximum pixel value break; } SaveBigInt(0); // Dummy value if (FName) { c = ilCharStrLen(FName); c = c < 79 ? 79 : c; iwrite(FName, 1, c); c = 80 - c; for (i = 0; i < c; i++) { iputc(0); } } else { for (i = 0; i < 80; i++) { iputc(0); } } SaveBigUInt(0); // Colormap // Padding for (i = 0; i < 101; i++) { SaveLittleInt(0); } if (iCurImage->Origin == IL_ORIGIN_UPPER_LEFT) { TempData = iGetFlipped(Temp); if (TempData == NULL) { if (Temp!= iCurImage) ilCloseImage(Temp); return IL_FALSE; } } else { TempData = Temp->Data; } if (!Compress) { for (c = 0; c < Temp->Bpp; c++) { for (i = c; i < Temp->SizeOfData; i += Temp->Bpp) { iputc(TempData[i]); // Have to save each colour plane separately. } } } else { iSaveRleSgi(TempData, Temp->Width, Temp->Height, Temp->Bpp, Temp->Bps); } if (TempData != Temp->Data) ifree(TempData); if (Temp != iCurImage) ilCloseImage(Temp); return IL_TRUE; }
// Internal function used to save the Sgi. ILboolean iSaveSgiInternal() { ILuint i, c; ILboolean Compress; ILimage *Temp = iCurImage; ILubyte *TempData; Compress = iGetInt(IL_SGI_RLE); if (iCurImage == NULL) { ilSetError(IL_ILLEGAL_OPERATION); return IL_FALSE; } if (iCurImage->Format != IL_RGB && iCurImage->Format != IL_RGBA) { if (iCurImage->Format == IL_BGRA) Temp = iConvertImage(iCurImage, IL_RGBA, DetermineSgiType(iCurImage->Type)); else Temp = iConvertImage(iCurImage, IL_RGB, DetermineSgiType(iCurImage->Type)); } else if (iCurImage->Type > IL_UNSIGNED_SHORT) { Temp = iConvertImage(iCurImage, iCurImage->Format, DetermineSgiType(iCurImage->Type)); } if (Temp == NULL) return IL_FALSE; SaveBigUShort(SGI_MAGICNUM); // 'Magic' number if (Compress) iputc(1); else iputc(0); if (Temp->Type == IL_UNSIGNED_BYTE) iputc(1); else if (Temp->Type == IL_UNSIGNED_SHORT) iputc(2); // Need to error here if not one of the two... if (Temp->Format == IL_LUMINANCE || Temp->Format == IL_COLOUR_INDEX) SaveBigUShort(2); else SaveBigUShort(3); SaveBigUShort((ILushort)Temp->Width); SaveBigUShort((ILushort)Temp->Height); SaveBigUShort((ILushort)Temp->Bpp); switch (Temp->Type) { case IL_BYTE: SaveBigInt(SCHAR_MIN); // Minimum pixel value SaveBigInt(SCHAR_MAX); // Maximum pixel value break; case IL_UNSIGNED_BYTE: SaveBigInt(0); // Minimum pixel value SaveBigInt(UCHAR_MAX); // Maximum pixel value break; case IL_SHORT: SaveBigInt(SHRT_MIN); // Minimum pixel value SaveBigInt(SHRT_MAX); // Maximum pixel value break; case IL_UNSIGNED_SHORT: SaveBigInt(0); // Minimum pixel value SaveBigInt(USHRT_MAX); // Maximum pixel value break; } SaveBigInt(0); // Dummy value if (FName) { c = strlen(FName); c = c < 79 ? 79 : c; iwrite(FName, 1, c); c = 80 - c; for (i = 0; i < c; i++) { iputc(0); } } else { for (i = 0; i < 80; i++) { iputc(0); } } SaveBigUInt(0); // Colormap // Padding for (i = 0; i < 101; i++) { SaveLittleInt(0); } if (iCurImage->Origin == IL_ORIGIN_UPPER_LEFT) { TempData = iGetFlipped(Temp); if (TempData == NULL) { if (Temp!= iCurImage) ilCloseImage(Temp); return IL_FALSE; } } else { TempData = Temp->Data; } if (!Compress) { for (c = 0; c < Temp->Bpp; c++) { for (i = c; i < Temp->SizeOfData; i += Temp->Bpp) { iputc(TempData[i]); // Have to save each colour plane separately. } } } else { iSaveRleSgi(TempData); } if (TempData != Temp->Data) ifree(TempData); if (Temp != iCurImage) ilCloseImage(Temp); return IL_TRUE; }