From 8ba1ac3479308f0b7b09af0bf0c438fa87b2ba8e Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 13 Jun 2019 13:48:32 +0300 Subject: [PATCH] Revert "0030182: Visualization, Image_AlienPixMap - support reading encoded image from memory buffer" This reverts commit 8866c0cdb815d9e48665f6337924190e822eb59f. --- src/Image/Image_AlienPixMap.cxx | 314 +++----------------------------- src/Image/Image_AlienPixMap.hxx | 22 +-- src/QABugs/QABugs_1.cxx | 139 +------------- src/QABugs/QABugs_17.cxx | 43 +++++ tests/bugs/vis/bug1188 | 18 +- tests/bugs/vis/bug25475 | 20 +- tests/bugs/vis/bug30182 | 64 ------- 7 files changed, 99 insertions(+), 521 deletions(-) delete mode 100644 tests/bugs/vis/bug30182 diff --git a/src/Image/Image_AlienPixMap.cxx b/src/Image/Image_AlienPixMap.cxx index 224cb8035f..e6bf80705a 100644 --- a/src/Image/Image_AlienPixMap.cxx +++ b/src/Image/Image_AlienPixMap.cxx @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include #include #include @@ -114,109 +112,6 @@ namespace return FIT_UNKNOWN; } } - - //! Wrapper for accessing C++ stream from FreeImage. - class Image_FreeImageStream - { - public: - //! Construct wrapper over input stream. - Image_FreeImageStream (std::istream& theStream) - : myIStream (&theStream), myOStream (NULL), myInitPos (theStream.tellg()) {} - - //! Get io object. - FreeImageIO GetFiIO() const - { - FreeImageIO anIo; - memset (&anIo, 0, sizeof(anIo)); - if (myIStream != NULL) - { - anIo.read_proc = readProc; - anIo.seek_proc = seekProc; - anIo.tell_proc = tellProc; - } - if (myOStream != NULL) - { - anIo.write_proc = writeProc; - } - return anIo; - } - public: - //! Simulate fread(). - static unsigned int DLL_CALLCONV readProc (void* theBuffer, unsigned int theSize, unsigned int theCount, fi_handle theHandle) - { - Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle; - if (aThis->myIStream == NULL) - { - return 0; - } - - if (!aThis->myIStream->read ((char* )theBuffer, std::streamsize(theSize) * std::streamsize(theCount))) - { - //aThis->myIStream->clear(); - } - const std::streamsize aNbRead = aThis->myIStream->gcount(); - return (unsigned int )(aNbRead / theSize); - } - - //! Simulate fwrite(). - static unsigned int DLL_CALLCONV writeProc (void* theBuffer, unsigned int theSize, unsigned int theCount, fi_handle theHandle) - { - Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle; - if (aThis->myOStream != NULL - && aThis->myOStream->write ((const char* )theBuffer, std::streamsize(theSize) * std::streamsize(theCount))) - { - return theCount; - } - return 0; - } - - //! Simulate fseek(). - static int DLL_CALLCONV seekProc (fi_handle theHandle, long theOffset, int theOrigin) - { - Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle; - if (aThis->myIStream == NULL) - { - return -1; - } - - bool isSeekDone = false; - switch (theOrigin) - { - case SEEK_SET: - if (aThis->myIStream->seekg ((std::streamoff )aThis->myInitPos + theOffset, std::ios::beg)) - { - isSeekDone = true; - } - break; - case SEEK_CUR: - if (aThis->myIStream->seekg (theOffset, std::ios::cur)) - { - isSeekDone = true; - } - break; - case SEEK_END: - if (aThis->myIStream->seekg (theOffset, std::ios::end)) - { - isSeekDone = true; - } - break; - } - return isSeekDone ? 0 : -1; - } - - //! Simulate ftell(). - static long DLL_CALLCONV tellProc (fi_handle theHandle) - { - Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle; - const long aPos = aThis->myIStream != NULL ? (long )(aThis->myIStream->tellg() - aThis->myInitPos) : 0; - return aPos; - } - private: - std::istream* myIStream; - std::ostream* myOStream; - std::streampos myInitPos; - }; - #elif defined(HAVE_WINCODEC) //! Return a zero GUID @@ -491,50 +386,21 @@ void Image_AlienPixMap::Clear() #endif } -// ======================================================================= -// function : IsTopDownDefault -// purpose : -// ======================================================================= -bool Image_AlienPixMap::IsTopDownDefault() -{ -#ifdef HAVE_FREEIMAGE - return false; -#elif defined(HAVE_WINCODEC) - return true; -#else - return false; -#endif -} - // ======================================================================= // function : Load // purpose : // ======================================================================= #ifdef HAVE_FREEIMAGE -bool Image_AlienPixMap::Load (const Standard_Byte* theData, - Standard_Size theLength, - const TCollection_AsciiString& theImagePath) +bool Image_AlienPixMap::Load (const TCollection_AsciiString& theImagePath) { Clear(); #ifdef _WIN32 const TCollection_ExtendedString aFileNameW (theImagePath); + FREE_IMAGE_FORMAT aFIF = FreeImage_GetFileTypeU (aFileNameW.ToWideString(), 0); +#else + FREE_IMAGE_FORMAT aFIF = FreeImage_GetFileType (theImagePath.ToCString(), 0); #endif - FREE_IMAGE_FORMAT aFIF = FIF_UNKNOWN; - FIMEMORY* aFiMem = NULL; - if (theData != NULL) - { - aFiMem = FreeImage_OpenMemory ((BYTE* )theData, (DWORD )theLength); - aFIF = FreeImage_GetFileTypeFromMemory (aFiMem, 0); - } - else - { - #ifdef _WIN32 - aFIF = FreeImage_GetFileTypeU (aFileNameW.ToWideString(), 0); - #else - aFIF = FreeImage_GetFileType (theImagePath.ToCString(), 0); - #endif - } if (aFIF == FIF_UNKNOWN) { // no signature? try to guess the file format from the file extension @@ -542,12 +408,10 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData, } if ((aFIF == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading (aFIF)) { - ::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported file format.", - Message_Fail); - if (aFiMem != NULL) - { - FreeImage_CloseMemory (aFiMem); - } + TCollection_AsciiString aMessage = "Error: image file '"; + aMessage.AssignCat (theImagePath); + aMessage.AssignCat ("' has unsupported file format."); + ::Message::DefaultMessenger()->Send (aMessage, Message_Fail); return false; } @@ -563,21 +427,11 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData, aLoadFlags = ICO_MAKEALPHA; } - FIBITMAP* anImage = NULL; - if (theData != NULL) - { - anImage = FreeImage_LoadFromMemory (aFIF, aFiMem, aLoadFlags); - FreeImage_CloseMemory (aFiMem); - aFiMem = NULL; - } - else - { - #ifdef _WIN32 - anImage = FreeImage_LoadU (aFIF, aFileNameW.ToWideString(), aLoadFlags); - #else - anImage = FreeImage_Load (aFIF, theImagePath.ToCString(), aLoadFlags); - #endif - } +#ifdef _WIN32 + FIBITMAP* anImage = FreeImage_LoadU (aFIF, aFileNameW.ToWideString(), aLoadFlags); +#else + FIBITMAP* anImage = FreeImage_Load (aFIF, theImagePath.ToCString(), aLoadFlags); +#endif if (anImage == NULL) { TCollection_AsciiString aMessage = "Error: image file '"; @@ -593,68 +447,10 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData, if (aFormat == Image_Format_UNKNOWN) { //anImage = FreeImage_ConvertTo24Bits (anImage); - ::Message::DefaultMessenger()->Send ( TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported pixel format.", - Message_Fail); - return false; - } - - Image_PixMap::InitWrapper (aFormat, FreeImage_GetBits (anImage), - FreeImage_GetWidth (anImage), FreeImage_GetHeight (anImage), FreeImage_GetPitch (anImage)); - SetTopDown (false); - - // assign image after wrapper initialization (virtual Clear() called inside) - myLibImage = anImage; - return true; -} - -bool Image_AlienPixMap::Load (std::istream& theStream, - const TCollection_AsciiString& theFileName) -{ - Clear(); - - Image_FreeImageStream aStream (theStream); - FreeImageIO aFiIO = aStream.GetFiIO(); - - FREE_IMAGE_FORMAT aFIF = FreeImage_GetFileTypeFromHandle (&aFiIO, &aStream, 0); - if (aFIF == FIF_UNKNOWN) - { - // no signature? try to guess the file format from the file extension - aFIF = FreeImage_GetFIFFromFilename (theFileName.ToCString()); - } - if ((aFIF == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading (aFIF)) - { - ::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image stream '") + theFileName + "' has unsupported file format.", - Message_Fail); - return false; - } - - int aLoadFlags = 0; - if (aFIF == FIF_GIF) - { - // 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading - aLoadFlags = GIF_PLAYBACK; - } - else if (aFIF == FIF_ICO) - { - // convert to 32bpp and create an alpha channel from the AND-mask when loading - aLoadFlags = ICO_MAKEALPHA; - } - - FIBITMAP* anImage = FreeImage_LoadFromHandle (aFIF, &aFiIO, &aStream, aLoadFlags); - if (anImage == NULL) - { - ::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image stream '") + theFileName + "' is missing or invalid.", - Message_Fail); - return false; - } - - Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage), - FreeImage_GetColorType(anImage), - FreeImage_GetBPP (anImage)); - if (aFormat == Image_Format_UNKNOWN) - { - ::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image stream '") + theFileName + "' has unsupported pixel format.", - Message_Fail); + TCollection_AsciiString aMessage = "Error: image file '"; + aMessage.AssignCat (theImagePath); + aMessage.AssignCat ("' has unsupported pixel format."); + ::Message::DefaultMessenger()->Send (aMessage, Message_Fail); return false; } @@ -666,46 +462,25 @@ bool Image_AlienPixMap::Load (std::istream& theStream, myLibImage = anImage; return true; } - #elif defined(HAVE_WINCODEC) -bool Image_AlienPixMap::Load (const Standard_Byte* theData, - Standard_Size theLength, - const TCollection_AsciiString& theFileName) +bool Image_AlienPixMap::Load (const TCollection_AsciiString& theImagePath) { Clear(); - Image_ComPtr aWicImgFactory; + IWICImagingFactory* aWicImgFactory = NULL; CoInitializeEx (NULL, COINIT_MULTITHREADED); - if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK) + if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory)) != S_OK) { Message::DefaultMessenger()->Send ("Error: cannot initialize WIC Imaging Factory", Message_Fail); return false; } Image_ComPtr aWicDecoder; - Image_ComPtr aWicStream; - if (theData != NULL) - { - if (aWicImgFactory->CreateStream (&aWicStream.ChangePtr()) != S_OK - || aWicStream->InitializeFromMemory ((BYTE* )theData, (DWORD )theLength) != S_OK) - { - Message::DefaultMessenger()->Send ("Error: cannot initialize WIC Stream", Message_Fail); - return false; - } - if (aWicImgFactory->CreateDecoderFromStream (aWicStream.get(), NULL, WICDecodeMetadataCacheOnDemand, &aWicDecoder.ChangePtr()) != S_OK) - { - Message::DefaultMessenger()->Send ("Error: cannot create WIC Image Decoder", Message_Fail); - return false; - } - } - else + const TCollection_ExtendedString aFileNameW (theImagePath); + if (aWicImgFactory->CreateDecoderFromFilename (aFileNameW.ToWideString(), NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &aWicDecoder.ChangePtr()) != S_OK) { - const TCollection_ExtendedString aFileNameW (theFileName); - if (aWicImgFactory->CreateDecoderFromFilename (aFileNameW.ToWideString(), NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &aWicDecoder.ChangePtr()) != S_OK) - { - Message::DefaultMessenger()->Send ("Error: cannot create WIC Image Decoder", Message_Fail); - return false; - } + Message::DefaultMessenger()->Send ("Error: cannot create WIC Image Decoder", Message_Fail); + return false; } UINT aFrameCount = 0, aFrameSizeX = 0, aFrameSizeY = 0; @@ -754,45 +529,10 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData, SetTopDown (true); return true; } -bool Image_AlienPixMap::Load (std::istream& theStream, - const TCollection_AsciiString& theFilePath) -{ - Clear(); - - // fallback copying stream data into transient buffer - const std::streamoff aStart = theStream.tellg(); - theStream.seekg (0, std::ios::end); - const Standard_Integer aLen = Standard_Integer(theStream.tellg() - aStart); - theStream.seekg (aStart); - if (aLen <= 0) - { - Message::DefaultMessenger()->Send ("Error: empty stream", Message_Fail); - return false; - } - - NCollection_Array1 aBuff (1, aLen); - if (!theStream.read ((char* )&aBuff.ChangeFirst(), aBuff.Size())) - { - Message::DefaultMessenger()->Send ("Error: unable to read stream", Message_Fail); - return false; - } - - return Load (&aBuff.ChangeFirst(), aBuff.Size(), theFilePath); -} #else -bool Image_AlienPixMap::Load (std::istream& , - const TCollection_AsciiString& ) -{ - Clear(); - Message::DefaultMessenger()->Send ("Error: no image library available", Message_Fail); - return false; -} -bool Image_AlienPixMap::Load (const Standard_Byte* , - Standard_Size , - const TCollection_AsciiString& ) +bool Image_AlienPixMap::Load (const TCollection_AsciiString&) { Clear(); - Message::DefaultMessenger()->Send ("Error: no image library available", Message_Fail); return false; } #endif @@ -1036,9 +776,9 @@ bool Image_AlienPixMap::Save (const TCollection_AsciiString& theFileName) return false; } - Image_ComPtr aWicImgFactory; + IWICImagingFactory* aWicImgFactory = NULL; CoInitializeEx (NULL, COINIT_MULTITHREADED); - if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK) + if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory)) != S_OK) { Message::DefaultMessenger()->Send ("Error: cannot initialize WIC Imaging Factory", Message_Fail); return false; diff --git a/src/Image/Image_AlienPixMap.hxx b/src/Image/Image_AlienPixMap.hxx index 14b1f40378..1e8a17948b 100644 --- a/src/Image/Image_AlienPixMap.hxx +++ b/src/Image/Image_AlienPixMap.hxx @@ -36,10 +36,6 @@ class Image_AlienPixMap : public Image_PixMap DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap) public: - //! Return default rows order used by underlying image library. - Standard_EXPORT static bool IsTopDownDefault(); -public: - //! Empty constructor. Standard_EXPORT Image_AlienPixMap(); @@ -47,23 +43,7 @@ public: Standard_EXPORT virtual ~Image_AlienPixMap(); //! Read image data from file. - bool Load (const TCollection_AsciiString& theFileName) - { - return Load (NULL, 0, theFileName); - } - - //! Read image data from stream. - Standard_EXPORT bool Load (std::istream& theStream, - const TCollection_AsciiString& theFileName); - - //! Read image data from memory buffer. - //! @param theData memory pointer to read from; - //! when NULL, function will attempt to open theFileName file - //! @param theLength memory buffer length - //! @param theFileName optional file name - Standard_EXPORT bool Load (const Standard_Byte* theData, - Standard_Size theLength, - const TCollection_AsciiString& theFileName); + Standard_EXPORT bool Load (const TCollection_AsciiString& theFileName); //! Write image data to file using file extension to determine compression format. Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName); diff --git a/src/QABugs/QABugs_1.cxx b/src/QABugs/QABugs_1.cxx index 9fbad4675d..b713c743cc 100644 --- a/src/QABugs/QABugs_1.cxx +++ b/src/QABugs/QABugs_1.cxx @@ -384,139 +384,6 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co return 0; } -#include -#include -#include -#include -#include -//======================================================================= -//function : OCC30182 -//purpose : Testing different interfaces of Image_AlienPixMap::Load() -//======================================================================= -static Standard_Integer OCC30182 (Draw_Interpretor& , Standard_Integer theNbArgs, const char** theArgVec) -{ - if (ViewerTest::CurrentView().IsNull()) - { - std::cout << "Error: no active view\n"; - return 1; - } - - TCollection_AsciiString aPrsName, anImgPath; - Standard_Integer anOffset = 0; - Standard_Integer aSrc = 0; // 0 - file name, 1 - file stream, 2 - memory buffer - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArg (theArgVec[anArgIter]); - anArg.LowerCase(); - if (anArg == "-offset" - && anArgIter + 1 < theNbArgs) - { - anOffset = Draw::Atoi (theArgVec[++anArgIter]); - } - else if (anArg == "-filename") - { - aSrc = 0; - } - else if (anArg == "-stream") - { - aSrc = 1; - } - else if (anArg == "-mem" - || anArg == "-memory") - { - aSrc = 2; - } - else if (aPrsName.IsEmpty()) - { - aPrsName = theArgVec[anArgIter]; - } - else if (anImgPath.IsEmpty()) - { - anImgPath = theArgVec[anArgIter]; - } - else - { - std::cout << "Syntax error at '" << anArg << "'\n"; - return 1; - } - } - if (anImgPath.IsEmpty()) - { - std::cout << "Syntax error: wrong number of arguments\n"; - return 1; - } - - Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap(); - if (aSrc == 0) - { - if (!anImage->Load (anImgPath)) - { - return 0; - } - } - else - { - std::ifstream aFile; - OSD_OpenStream (aFile, anImgPath.ToCString(), std::ios::in | std::ios::binary); - if (!aFile.is_open()) - { - std::cout << "Syntax error: image file '" << anImgPath << "' cannot be found\n"; - return 1; - } - if (anOffset != 0) - { - aFile.seekg (anOffset); - } - - if (aSrc == 2) - { - aFile.seekg (0, std::ios::end); - Standard_Integer aLen = (Standard_Integer )aFile.tellg() - anOffset; - aFile.seekg (anOffset); - if (aLen <= 0) - { - std::cout << "Syntax error: wrong offset\n"; - return 1; - } - NCollection_Array1 aBuff (1, aLen); - if (!aFile.read ((char* )&aBuff.ChangeFirst(), aBuff.Size())) - { - std::cout << "Error: unable to read file\n"; - return 1; - } - aFile.close(); - if (!anImage->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath)) - { - return 0; - } - } - else - { - if (!anImage->Load (aFile, anImgPath)) - { - return 0; - } - } - } - - TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100.0 * anImage->Ratio(), 100.0, 1.0).Shape(); - Handle(AIS_Shape) aPrs = new AIS_Shape (aShape); - aPrs->SetDisplayMode (AIS_Shaded); - //aPrs->Attributes()->SetupOwnShadingAspect(); // corrected after porting on current master - const Handle(Graphic3d_AspectFillArea3d)& anAspect = aPrs->Attributes()->ShadingAspect()->Aspect(); - anAspect->SetShadingModel (Graphic3d_TOSM_UNLIT); - anAspect->SetTextureMapOn (true); - anAspect->SetTextureMap (new Graphic3d_Texture2Dmanual (anImage)); - if (anImage->IsTopDown()) - { - anAspect->TextureMap()->GetParams()->SetTranslation(Graphic3d_Vec2 (0.0f, -1.0f)); - anAspect->TextureMap()->GetParams()->SetScale (Graphic3d_Vec2 (1.0f, -1.0f)); - } - - ViewerTest::Display (aPrsName, aPrs, true, true); - return 0; -} - void QABugs::Commands_1(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -530,9 +397,7 @@ void QABugs::Commands_1(Draw_Interpretor& theCommands) { theCommands.Add ("OCC74_set", "OCC74_set shape mode; set selection mode", __FILE__, OCC74bug_set, group); theCommands.Add ("OCC74_get", "OCC74_get shape; get selection mode", __FILE__, OCC74bug_get, group); - theCommands.Add ("OCC361", "OCC361 Doc ", __FILE__, OCC361bug, group); - theCommands.Add ("OCC30182", - "OCC30182 name image [-offset Start] [-fileName] [-stream] [-memory]\n" - "Decodes image either by passing file name, file stream or memory stream", __FILE__, OCC30182, group); + theCommands.Add("OCC361", "OCC361 Doc ", __FILE__, OCC361bug, group); + return; } diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 86ed992132..f0e1a8abd7 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -1078,6 +1078,48 @@ static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, con return 0; } +#include +//======================================================================= +//function : OCC1188 +//purpose : +//======================================================================= +static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if (argc < 2 || argc > 3) + { + di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n"; + return 1; + } + + Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext(); + if(AISContext.IsNull()) + { + di << "use 'vinit' command before " << argv[0] << "\n"; + return 1; + } + + Aspect_FillMethod aFillType = Aspect_FM_CENTERED; + if (argc == 3) + { + const char* szType = argv[2]; + if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; + else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; + else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; + else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; + else + { + di << "Wrong fill type : " << szType << "\n"; + di << "Must be one of CENTERED, TILED, STRETCH, NONE\n"; + return 1; + } + } + + Handle(V3d_View) V3dView = ViewerTest::CurrentView(); + V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True); + + return 0; +} + #include #include #include @@ -1548,6 +1590,7 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) { theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group); theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group); theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group); + theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group); theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group); theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group); diff --git a/tests/bugs/vis/bug1188 b/tests/bugs/vis/bug1188 index 53af177e6f..1f584dc02d 100755 --- a/tests/bugs/vis/bug1188 +++ b/tests/bugs/vis/bug1188 @@ -1,11 +1,19 @@ puts "================" -puts "0001188: Impossible to set background image for V3d_View" +puts "OCC1188" +puts "Impossible to set background image for V3d_View" puts "================" puts "" -vinit View1 +set x 200 +set y 200 -vsetbg [locate_data_file OCC1188.gif] -if { [vreadpixel 200 200 rgb name] != "WHITE" } { puts "Error: image background is not set" } +vinit -vdump $imagedir/${casename}.png +OCC1188 [locate_data_file OCC1188.gif] + +checkcolor $x $y 0.99 0.99 0.99 +if { ${stat} != 1} { + puts "OCC1188: Error" +} + +checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/vis/bug25475 b/tests/bugs/vis/bug25475 index 1ba94b020f..2169acd4d2 100644 --- a/tests/bugs/vis/bug25475 +++ b/tests/bugs/vis/bug25475 @@ -1,24 +1,30 @@ puts "============" -puts "0025475: Visualization, TKOpenGl - draw background using primitive arrays" -puts "Tests textured background" +puts "OCC25475" puts "============" puts "" +####################################################################### +puts "Tests textured background" +####################################################################### set aTextureFile [locate_data_file hatch_1.png] +set anImage1 $imagedir/${casename}_1.png +set anImage2 $imagedir/${casename}_2.png +set anImage3 $imagedir/${casename}_3.png +set anImage4 $imagedir/${casename}_4.png pload VISUALIZATION -vinit View1 +vinit vsetbg $aTextureFile STRETCH -vdump $imagedir/${casename}_1.png +vdump $anImage1 vsetbg $aTextureFile NONE vsetbg $aTextureFile TILED -vdump $imagedir/${casename}_2.png +vdump $anImage2 vsetgradientbg 255 0 0 0 0 255 1 vsetbg $aTextureFile CENTERED -vdump $imagedir/${casename}_3.png +vdump $anImage3 vsetbg $aTextureFile NONE -vdump $imagedir/${casename}_4.png +vdump $anImage4 diff --git a/tests/bugs/vis/bug30182 b/tests/bugs/vis/bug30182 deleted file mode 100644 index 9b8978e03f..0000000000 --- a/tests/bugs/vis/bug30182 +++ /dev/null @@ -1,64 +0,0 @@ -puts "============" -puts "0030182: Visualization, Image_AlienPixMap - support reading encoded image from memory buffer" -puts "============" -puts "" - -set anImg1 [locate_data_file hatch_1.png] -set anImg2 [locate_data_file OCC1188.gif] -set anImgTmp "$imagedir/${casename}_img.bin" - -set aTmpOut [open "$anImgTmp" w] -fconfigure $aTmpOut -translation binary -foreach aFileIter {anImg1 anImg2} { - set aFileName [set $aFileIter] - set aFileIn [open $aFileName] - fconfigure $aFileIn -translation binary - fcopy $aFileIn $aTmpOut - close $aFileIn -} -close $aTmpOut - -pload VISUALIZATION QAcommands -vclear -vinit View1 -vtop - -OCC30182 t $anImg1 -fileName; vfit -vdump $imagedir/${casename}_1.png - -OCC30182 t $anImg1 -stream; vfit -vdump $imagedir/${casename}_1s1.png - -OCC30182 t $anImg1 -memory; vfit -vdump $imagedir/${casename}_1m1.png - -OCC30182 t $anImg2 -fileName; vfit -vdump $imagedir/${casename}_2.png - -OCC30182 t $anImg2 -stream; vfit -vdump $imagedir/${casename}_2s1.png - -OCC30182 t $anImg2 -memory; vfit -vdump $imagedir/${casename}_2m1.png - -OCC30182 t $anImgTmp -stream -offset 0; vfit -vdump $imagedir/${casename}_1s2.png - -OCC30182 t $anImgTmp -memory -offset 0; vfit -vdump $imagedir/${casename}_1m2.png - -OCC30182 t $anImgTmp -stream -offset [file size $anImg1]; vfit -vdump $imagedir/${casename}_2s2.png - -OCC30182 t $anImgTmp -memory -offset [file size $anImg1]; vfit -vdump $imagedir/${casename}_2m2.png - -if { [diffimage $imagedir/${casename}_1s1.png $imagedir/${casename}_1.png] != 0 } { puts "Error 1s1" } -if { [diffimage $imagedir/${casename}_1m1.png $imagedir/${casename}_1.png] != 0 } { puts "Error 1m1" } -if { [diffimage $imagedir/${casename}_1s2.png $imagedir/${casename}_1.png] != 0 } { puts "Error 1s2" } -if { [diffimage $imagedir/${casename}_1m2.png $imagedir/${casename}_1.png] != 0 } { puts "Error 1m2" } - -if { [diffimage $imagedir/${casename}_2s1.png $imagedir/${casename}_2.png] != 0 } { puts "Error 2s1" } -if { [diffimage $imagedir/${casename}_2m1.png $imagedir/${casename}_2.png] != 0 } { puts "Error 2m1" } -if { [diffimage $imagedir/${casename}_2s2.png $imagedir/${casename}_2.png] != 0 } { puts "Error 2s2" } -if { [diffimage $imagedir/${casename}_2m2.png $imagedir/${casename}_2.png] != 0 } { puts "Error 2m2" } -- 2.39.5