Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Memoryfile

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 402 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 26/09/2011 at 12:28, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   12/13 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      I have a base bitmap (jpeg) and a valid pointer to the memory to store.
      How would one use "MemoryFileStruct" and "SetMemoryWriteMode" or should this be done differently?

      Jan

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 27/09/2011 at 06:00, xxxxxxxx wrote:

        The MemoryFileStruct class is is only used to write/read to memory instead of files. It basically replaces a filename.

        here an example that writes a line of characters and prints the retrieved data.

          
        Bool MenuTest::Execute(BaseDocument *doc)  
        {  
          AutoAlloc<MemoryFileStruct> mfs;  
          if (!mfs) return FALSE;  
          
          Filename fn;  
          fn.SetMemoryWriteMode(mfs);  
          
          AutoAlloc<BaseFile> file;  
          if (!file) return FALSE;  
          
          if (!file->Open(fn, FILEOPEN_WRITE, FILEDIALOG_IGNOREOPEN, BYTEORDER_INTEL)) return FALSE;  
          
          CHAR *line = "hello world!";  
          
          //write something to the memory file  
          if (!file->WriteBytes(line, strlen(line))) return FALSE;  
          
          void *testline = NULL;  
          VLONG length = 0;  
          
          //get the written data  
          mfs->GetData(testline, length, FALSE);  
          
          if (!testline) return FALSE;  
          
          String str((CHAR* )testline);  
          
          GePrint(str);  
          
          return TRUE;  
        }  
        

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 27/09/2011 at 08:55, xxxxxxxx wrote:

          I see.
          But my target is to save a freshly rendered preview in a base bitmap (jpeg) to an already initialized pointer in memory.
          It seems to me that i cannot use the basefile in this case.

          What are my options? What is possible?
          I need to do this in realtime and as fast as possible. A preview is good enough.

          1.Render directly in the memory already initialized?
          2.Maybe by getting a handle to the jpeg data in the base bitmap? Can that be done?
          3.Or a handle to the offscreen rendered preview? That is also a lot more efficient, because I would not need to force an extra render. .

          Jan

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 28/09/2011 at 02:53, xxxxxxxx wrote:

            Do you mean viewport rendering?

            Anyways, saving a JPG to memory seems to work as follows:

              
            Bool MenuTest::Execute(BaseDocument *doc)  
            {  
              AutoAlloc<MemoryFileStruct> mfs;  
              if (!mfs) return FALSE;  
              
              Filename fn;  
              fn.SetMemoryWriteMode(mfs);  
              
              BaseBitmap *bmp = NULL;  
              bmp = BaseBitmap::Alloc();  
              if (!bmp) return FALSE;  
              
              BaseContainer bc;  
              bc.SetLong(JPGSAVER_QUALITY, 80);  
              
              void *mbmp = NULL;  
              VLONG length = 0;  
              
              if (bmp->Init(1024,512) != IMAGERESULT_OK) goto Error;  
              
              bmp->Clear(255,0,0);  
              
              if (bmp->Save(fn, FILTER_JPG, &bc, SAVEBIT_0) != IMAGERESULT_OK) goto Error;  
              
              GePrint("saved");  
              
              //get the written data  
              mfs->GetData(mbmp, length, FALSE);  
              if (!mbmp) goto Error;  
              
              // mbmp is the pointer to the JPG data  
              
              GePrint(LongToString(length));  
              
              return TRUE;  
              
            Error:  
              BaseBitmap::Free(bmp);  
              return FALSE;  
            }  
            

            Hope that helps.

            cheers,
            Matthias

            1 Reply Last reply Reply Quote 0
            • First post
              Last post