bool nuiImageDropZone::SetImage(const nglPath& rPath) { if (!rPath.Exists()) return false; mPath = rPath; mpImage->Trash(); mpImage = new nuiImage(mPath); AddChild(mpImage); return true; }
bool ConvertCompressedAudioFile(nglPath inPath, nglPath outPath) { if (!inPath.Exists()) return false; bool res = false; //INPUT nglIFile inFile(inPath); nuiAudioDecoder* pDecoder = new nuiAudioDecoder(inFile); //OUTPUT nglOFile outFile(outPath, eOFileCreate); nuiWaveWriter* pWriter = new nuiWaveWriter(outFile); nuiSampleInfo inInfo; nuiSampleInfo outInfo; if (pDecoder->GetInfo(inInfo)) { NGL_OUT(_T("********************************************************\Audio infos:\n")); PrintAudioInfos(inInfo); uint32 channels = inInfo.GetChannels(); float* pInterleavedBuffer = new float[channels * FRAMES_PACKET]; //write output samples infos outInfo.SetChannels(inInfo.GetChannels()); outInfo.SetSampleRate(inInfo.GetSampleRate()); outInfo.SetBitsPerSample(inInfo.GetBitsPerSample()); outInfo.SetFileFormat(eAudioWave); outInfo.SetFormatTag(eWaveFormatPcm); pWriter->WriteInfo(outInfo); uint32 FramesToRead = FRAMES_PACKET; uint32 FramesRead = 0; uint32 FramesWritten = 0; uint32 TotalFramesRead = 0; uint32 TotalFramesWritten = 0; do { FramesRead = pDecoder->ReadIN(pInterleavedBuffer, FramesToRead); FramesWritten = pWriter->Write(pInterleavedBuffer, FramesRead, eSampleFloat32); TotalFramesRead += FramesRead; TotalFramesWritten += FramesWritten; } while (FramesRead); NGL_OUT(_T("SUCCESS: FILE DECOMPRESSED\n")); NGL_OUT(_T("%ld samples read and %ld samples written\n"), TotalFramesRead, TotalFramesWritten); //finalize wave file writing if (!pWriter->Finalize()) NGL_OUT(_T("nuiWaveWriter: Failed to finalize!!!!!!!\n")); delete[] pInterleavedBuffer; res = true; }