Jump to content

  • Log In with Google      Sign In   
  • Create Account

WICTextureLoader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 27 November 2012 - 12:32 PM

Hello,

I am trying to use the WICTextureLoader functions as provided by Frank Luna, and I keep branching to return E_NOINTERFACE. Here is how the code goes:

HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
_In_bytecount_(wicDataSize) const uint8_t* wicData,
_In_ size_t wicDataSize,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize
)
{
if (!d3dDevice || !wicData || (!texture && !textureView))
{
return E_INVALIDARG;
}
if ( !wicDataSize )
{
return E_FAIL;
}
#ifdef _M_AMD64
if ( wicDataSize > 0xFFFFFFFF )
return HRESULT_FROM_WIN32( ERROR_FILE_TOO_LARGE );
#endif
IWICImagingFactory* pWIC = _GetWIC();
if ( !pWIC )
return E_NOINTERFACE;

----------------
I read somewhere that this has something to do with not calling CoInitializeEx(), but since I know nothing about COM objects except for the fact that Direct3D and Windows use them heavily, I was hoping somebody could help me figure out where in my code to call CoInitializeInstanceEx() and what parameters to use, or if this is not the problem at all.

Thanks in advance.

-Dave Ottley

I wonder as I wander...

http://www.davesgameoflife.com


Sponsor:

#2 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 27 November 2012 - 01:08 PM

Nevermind, screw it. I'm going to write my own .PNG parser/decryptor.

I wonder as I wander...

http://www.davesgameoflife.com


#3 eppo   Crossbones+   -  Reputation: 2621

Like
0Likes
Like

Posted 27 November 2012 - 01:20 PM

Not sure what _GetWIC() does, but try to manually create a Factory:

CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (void**)&pWIC);

#4 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 27 November 2012 - 01:35 PM

eppo,

Here is the code for _GetWIC(), which fails with REGDB_E_CLASSNOTREG:

static IWICImagingFactory* _GetWIC()
{
static IWICImagingFactory* s_Factory = nullptr;
if ( s_Factory )
return s_Factory;
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
(LPVOID*)&s_Factory
);
if ( FAILED(hr) )
{
s_Factory = nullptr;
return nullptr;
}
return s_Factory;
}

I wonder as I wander...

http://www.davesgameoflife.com


#5 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
1Likes
Like

Posted 27 November 2012 - 01:47 PM

Cut-n-paste the full source at the bottom of this link:

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476904(v=vs.85).aspx

#6 eppo   Crossbones+   -  Reputation: 2621

Like
0Likes
Like

Posted 27 November 2012 - 01:58 PM

If you haven't called CoInitializeEx(), CoCreateInstance() should return something implying you haven't so.

Try changing CLSID_WICImagingFactory to CLSID_WICImagingFactory1.

#7 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 27 November 2012 - 02:17 PM

Steve: I tried that link but nothing was available... :(

eppo: I tried adding the 1 and it worked! Wow, Microsoft madness. Can you explain why that worked?

Thanks in advance.

-Dave Ottley

I wonder as I wander...

http://www.davesgameoflife.com


#8 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 27 November 2012 - 02:26 PM

This is unrelated, but I thought I'd take this opportunity to ask why when I write:

assert(buffer[imageDataStartsHere] == 89 && "Image data does not really start here.");

The error message I receive is: Expression: buffer[imageDataStartsHere] == 89 && "Image data does not really start here."

I just wanted the stuff in double quotes. Is there any way to get this?

Thanks.

-Dave Ottley

I wonder as I wander...

http://www.davesgameoflife.com


#9 eppo   Crossbones+   -  Reputation: 2621

Like
1Likes
Like

Posted 27 November 2012 - 02:38 PM

You were probably targeting the x64 platform. The old CLSID_WICImagingFactory is registered as a 32 bit COM object.

#10 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
0Likes
Like

Posted 27 November 2012 - 03:15 PM

Sorry somehow the link got cut.

"http://msdn.microsoft.com/en-us/library/windows/desktop/ff476904(v=vs.85).aspx"

Edited by Steve_Segreto, 27 November 2012 - 03:15 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS