User Tag List

Results 1 to 3 of 3

Thread: Loading images

  1. #1
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, ┼rhus
    Posts
    3,455
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Loading images

    For some reason I can't even load an image (bmp) into a surface using their LoadImage function. They always return false.

    I then want to use the new image filter stuff so I can load any image MMF2 can do with it's filters. The SDK just confuses me a bit.
    Should I use ImportImage() or should I use the LoadImageFile() function from the SDK example?

  2. #2
    No Products Registered

    Join Date
    Jun 2006
    Location
    Texas
    Posts
    1,002
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Loading images

    Hey. Here are the loading and saving routines for my Overlay update. They still need some work (saving s not 100% yet) so if you improve them then please send me the updated source code in order to save me the work :P .

    Code:
    // Load image from file 
    BOOL LoadImageFile(LPRDATA rdPtr, LPSURFACE psf, LPSTR pFileName, DWORD dwFlags) 
    { 
    	BOOL    bOK = FALSE; 
    	LPRH    rhPtr = rdPtr->rHo.hoAdRunHeader; 
    	HANDLE    hf = INVALID_HANDLE_VALUE; 
    
    	do { 
    		if ( pFileName == NULL || *pFileName == 0 ) 
    			break; 
    
    		// Copy filename to temporary string 
    		char fname[MAX_PATH]; 
    		strcpy(fname, pFileName); 
    
    		// Open file 
    		// 
    		// mvOpenHFile opens the file directly from the CCN/EXE file ifthe file has been included in the embedded binary files of the application. 
    		// If the file is not embedded, mvOpenHFile opens it from its current location (and downloads it first in Vitalize mode). 
    		// 
    		DWORD dwSize;                                    // file size 
    		hf = rhPtr->rh4.rh4Mv->mvOpenHFile(fname, &dwSize, 0); 
    		if ( hf == INVALID_HANDLE_VALUE ) 
    			break; 
    
    		// Create CInputFile 
    		DWORD dwOff = File_GetPosition((HFILE)hf);        // position of embedded file in CCN/EXE file (0 if not embedded) 
    		CInputBufFile bf; 
    		if ( bf.Create((HFILE)hf, dwOff, dwSize) != 0 ) 
    			break; 
    
    		// Load picture 
    		if ( ImportImageFromInputFile(rhPtr->rh4.rh4Mv->mvImgFilterMgr, &bf, psf, NULL, dwFlags) ) 
    			bOK = TRUE; 
    
    	} while(FALSE); 
    
    	if ( hf != INVALID_HANDLE_VALUE ) 
    		rhPtr->rh4.rh4Mv->mvCloseHFile(hf); 
    
    	return bOK; 
    } 
    
    
    short WINAPI DLLExport actLoadImage(LPRDATA rdPtr, long param1, long param2)
    {
    	char* p1 = reinterpret_cast<char*>(CNC_GetStringParameter(rdPtr));
    	cSurface * workSurface = new cSurface;
    	workSurface->Clone(*rdPtr->runSurface,1,1);
    	if(LoadImageFile(rdPtr,workSurface,p1))
    	{
    		//rdPtr->rFilename=p1;
    		rdPtr->oldwidth = workSurface->GetWidth();
    		rdPtr->oldheight = workSurface->GetHeight();
    
    		if(rdPtr->stretching)
    		{
    			//stretch image
    			workSurface->Stretch(*rdPtr->runSurface,STRF_COPYALPHA);
    			workSurface->Delete();
    			delete workSurface;
    		}
    		else
    		{
    			//resize overlay to fit image
    			rdPtr->swidth = rdPtr->oldwidth;
    			rdPtr->sheight = rdPtr->oldheight;
    			rdPtr->runSurface->Delete();
    			delete rdPtr->runSurface;
    			rdPtr->runSurface = workSurface;
    		}				
    
    		//update display
    		UpDisp(rdPtr);
    	}
    	else
    	{
    		workSurface->Delete();
    		delete workSurface;
    	}
    
    	return 0;
    }
    DWORD FindFilter(LPRDATA rdPtr,CImageFilterMgr *pImgMgr,LPCSTR filepath)
    {
    	std::string FileStr=filepath;
    	std::string::size_type findex = std::string::npos;
    	int index=-1;
    	int bmpindex=0;
    	findex=FileStr.find_last_of('.')+1;
    	for(int i=0;i<pImgMgr->GetFilterCount();i++)
    	{
    		if(pImgMgr->DoesFilterSupportImages(i))
    		{
    			LPCSTR*mFileExts=pImgMgr->GetFilterExts(i);
    			LPCSTR ExtStr=NULL;
    			ExtStr=(*mFileExts++);
    			while(ExtStr!=NULL)
    			{
    				if(std::string(ExtStr)==std::string("bmp"))
    					bmpindex=i;
    				if(FileStr.substr(findex)==std::string(ExtStr))
    				{
    					index=i;
    					break;
    				}
    				ExtStr=(*mFileExts++);
    			}
    			if(index!=-1)
    				break;
    		}
    	}
    	if(index==-1)
    		index=bmpindex;
    	MessageBox(NULL,pImgMgr->GetFilterName(index),"Test",NULL);
    	return pImgMgr->GetFilterID(index);
    }
    
    short WINAPI DLLExport actSaveImage(LPRDATA rdPtr, long param1, long param2)
    {
    	fprh	rhPtr = rdPtr->rHo.hoAdRunHeader;
    	CImageFilterMgr* pImgMgr = rhPtr->rh4.rh4Mv->mvImgFilterMgr;
    	DWORD mFilter=NULL;
    	//pImgMgr=pImgMgr->CreateInstance();
    #if defined(VITALIZE)
    	return 0;
    #else
    	if(rdPtr->runSurface!= NULL)
    	{
    		mFilter=FindFilter(rdPtr,pImgMgr,(LPCSTR)param1);
    
    		if(!ExportImage(pImgMgr,(LPCSTR)param1,rdPtr->runSurface,mFilter))
    		{
    			LPSURFACE pProto = NULL;
    			int depth=24;
    			CImageFilter pFilter(pImgMgr);
    			pFilter.UseSpecificFilterID(mFilter);
    
    			if ( GetSurfacePrototype(&pProto, depth, ST_MEMORYWITHDC, SD_DIB) )
    			{
    				// OK
    				cSurface * wNA = new cSurface();
    				if (wNA!= NULL)
    				{
    					wNA->Create(rdPtr->swidth,rdPtr->sheight,pProto);
    					rdPtr->runSurface->Blit(*wNA,0,0,BMODE_OPAQUE,BOP_COPY,0);
    					ExportImage(pImgMgr,(LPCSTR)param1,wNA,mFilter);
    					delete wNA;
    				}
    
    			}
    		}
    	}
    
    	return 0;
    #endif
    }
    Hope it helps.

  3. #3
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, ┼rhus
    Posts
    3,455
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Loading images

    The loading works perfectly thanks :-)
    I'll have a look at the saving routine, though I won't be using it in the Parallaxer object.

Similar Threads

  1. Images loading from url
    By crayzorechos in forum iOS Export Module Version 2.0
    Replies: 7
    Last Post: 29th April 2013, 05:03 PM
  2. Problem with loading images in the frame editor!
    By Koji_Kabuto in forum iOS Export Module Version 2.0
    Replies: 18
    Last Post: 23rd March 2012, 11:56 AM
  3. issue when loading importing .bmp images
    By willow in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 1st August 2011, 05:51 PM
  4. Loading Images from HTTP://
    By Doverseer in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 5th February 2008, 06:00 AM
  5. syntax when loading images from a subfolder
    By BrashMonkey in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 30th January 2008, 07:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •