]> OCCT Git - occt-copy.git/commitdiff
Revert "0030182: Visualization, Image_AlienPixMap - support reading encoded image...
authornds <nds@opencascade.com>
Thu, 13 Jun 2019 10:48:32 +0000 (13:48 +0300)
committernds <nds@opencascade.com>
Thu, 13 Jun 2019 10:48:32 +0000 (13:48 +0300)
This reverts commit 8866c0cdb815d9e48665f6337924190e822eb59f.

src/Image/Image_AlienPixMap.cxx
src/Image/Image_AlienPixMap.hxx
src/QABugs/QABugs_1.cxx
src/QABugs/QABugs_17.cxx
tests/bugs/vis/bug1188
tests/bugs/vis/bug25475
tests/bugs/vis/bug30182 [deleted file]

index 224cb8035fa1c0eeb36bdcc84190615df2aa0e4a..e6bf80705a8e14596dfe67fae58454834ff6b5a1 100644 (file)
@@ -36,8 +36,6 @@
 #include <gp.hxx>
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
-#include <NCollection_Array1.hxx>
-#include <Standard_ArrayStreamBuffer.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <OSD_OpenFile.hxx>
@@ -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<IWICImagingFactory> 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<IWICBitmapDecoder> aWicDecoder;
-  Image_ComPtr<IWICStream> 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<Standard_Byte> 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<IWICImagingFactory> 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;
index 14b1f40378d2d96a0ca002df187d2a9675639173..1e8a17948bb6931c3a334b582dea7c110f67e92d 100644 (file)
@@ -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);
index 9fbad4675d21ab575adeb546600ab66a54e8110f..b713c743cca67c3f98a3c1f01cc1d0e0646632b2 100644 (file)
@@ -384,139 +384,6 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co
   return 0;
 }
 
-#include <Graphic3d_Texture2Dmanual.hxx>
-#include <Image_AlienPixMap.hxx>
-#include <OSD_OpenFile.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Standard_ArrayStreamBuffer.hxx>
-//=======================================================================
-//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<Standard_Byte> 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;
 }
index 86ed992132379d2a2f4193e48d390ebf46d1de16..f0e1a8abd74e4854876f51b279cb04c4d41643eb 100644 (file)
@@ -1078,6 +1078,48 @@ static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, con
   return 0;
 }
 
+#include <Aspect_FillMethod.hxx>
+//=======================================================================
+//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 <Graphic3d_MaterialAspect.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_ShadingAspect.hxx>
@@ -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);
index 53af177e6f71e4325d3daac21d7887a302a1db58..1f584dc02db3442768334772e2fbf88fc0844722 100755 (executable)
@@ -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
index 1ba94b020f31c6cecd2d6cd3ec2f545ba9f9f4d6..2169acd4d28168f5e8da05c4cbc8c5f190cc7ec0 100644 (file)
@@ -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 (file)
index 9b8978e..0000000
+++ /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" }