void VJSImage::_save(XBOX::VJSParms_callStaticFunction& ioParms, VJSPictureContainer* inPict)
{
	VPictureCodecFactoryRef fact;
	const VPictureCodec* encoder = nil;
	bool ok = false;

	VPicture* pic = inPict->GetPict();
	if (pic != nil)
	{
		VFile* file = ioParms.RetainFileParam(1);
		if (file != nil)
		{
			VString mimetype;
			ioParms.GetStringParam(2, mimetype);
			if (mimetype.IsEmpty())
			{
				VString extension;
				file->GetExtension(extension);
				if (extension.IsEmpty())
					extension = L"pic";
				encoder = fact->RetainEncoderForExtension(extension);
			}
			else
				encoder = fact->RetainEncoderByIdentifier(mimetype);

			if (encoder != nil)
			{
				VError err = VE_OK;
				if (file->Exists())
					err = file->Delete();
				if (err == VE_OK)
				{
					VValueBag *pictureSettings = nil;

					VValueBag *bagMetas = (VValueBag*)inPict->RetainMetaBag();
					if (bagMetas != nil)
					{
						pictureSettings = new VValueBag();
						ImageEncoding::stWriter settingsWriter(pictureSettings);
						VValueBag *bagRetained = settingsWriter.CreateOrRetainMetadatas( bagMetas);
						if (bagRetained) 
							bagRetained->Release(); 
					}
					err=encoder->Encode(*pic, pictureSettings, *file);

					QuickReleaseRefCountable(bagMetas);
					QuickReleaseRefCountable(pictureSettings);

					if (err == VE_OK)
						ok = true;
				}
				encoder->Release();
			}
			file->Release();
		}
		else
			vThrowError(VE_JVSC_WRONG_PARAMETER_TYPE_FILE, "1");
	}
	ioParms.ReturnBool(ok);
}
Esempio n. 2
0
void VJSSharedWorkerClass::_IsRunning (XBOX::VJSParms_callStaticFunction &ioParms, void *)
{
    XBOX::VString	url, name;

    if (!ioParms.GetStringParam(1, url))

        XBOX::vThrowError(XBOX::VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1");

    else if (!ioParms.GetStringParam(2, name))

        XBOX::vThrowError(XBOX::VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "2");

    else

        ioParms.ReturnBool(VJSWorker::IsSharedWorkerRunning(url, name));
}