Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HRESULT ContentResource::AddResource( _CONTENT_ASSET assetType, ContentAssetPack * assetPack, BYTE * fileData, DWORD fileSize, IMAGE_TYPE imageType, DWORD screenshotIndex = 0 )
- {
- // First thing we need to do is convert our incoming file to raw image data
- if( S_FALSE == CreateRawResource( fileData, fileSize, imageType ) ) return S_FALSE;
- // If successful, let's fill out our struct that describes our raw image
- TEXTURE_SOURCE texSource;
- texSource.ImageData = resourceData;
- texSource.ImageFormat = resourceFormat;
- texSource.ImageHeight = resourceHeight;
- texSource.ImageWidth = resourceWidth;
- texSource.ImagePitch = resourcePitch;
- texSource.ImageSize = resourceSize;
- // Pass struct to the conversion class, and if it fails, we fail
- CTexture2D texConvert( texSource );
- if( S_FALSE == texConvert.CreateTexture()) return S_FALSE;
- // Next let's grab pointers to our converted data, this is the information stored in our file
- BYTE * headerData = NULL; DWORD headerDataSize = 0;
- BYTE * videoData = NULL; DWORD videoDataSize = 0;
- headerData = texConvert.GetHeaderPtr( &headerDataSize );
- videoData = texConvert.GetVideoDataPtr( &videoDataSize );
- // Let's do a quick compability test on the header size (if not size 0x34, let's bail)
- if( headerDataSize != 0x34 ) {
- LOG("ContentResource", "Asset Conversion Failure- Mismatched Header Sizes. 0x%X =/= 0x34", headerDataSize );
- return S_FALSE;
- }
- // Next let's analyze the asset type and see if it exists in our current assetPack
- BOOL bAssetExists = assetPack->EntryExists( assetType, screenshotIndex );
- // Now we add / modify our assetPack depending on above result
- if( bAssetExists == TRUE )
- {
- if( assetType == ASSET_SCREENSHOT ) {
- return assetPack->ModifyScreenshotEntry( screenshotIndex, headerData, videoData, videoDataSize );
- } else {
- return assetPack->ModifyAssetEntry( assetType, headerData, videoData, videoDataSize );
- }
- }
- else
- {
- return assetPack->AddEntry( assetType, headerData, videoData, videoDataSize );
- }
- // if we got here, there something went way wrong
- return S_FALSE;
- }
Add Comment
Please, Sign In to add comment