Background Image

Forum for discussion on different user applications
Locked
doug.davies
Posts: 12
Joined: 09 Jun 2011, 13:07

Background Image

Post by doug.davies » 14 Jun 2011, 15:39

Hi all,
I am working on an application that presents 2d image stimuli in front of a 2d image background. It is a very similar idea to the StimulusPresentation module, except that the stimuli need to show up in front of a background image.
I feel that this should be a fairly trivial change, but I have been unsuccessful so far in making my application display a static image. If anyone has an advice or a solution it would be greatly appreciated.

Thanks,
Doug Davies
UC Berkeley

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: Background Image

Post by mellinger » 17 Jun 2011, 10:57

Hi Doug,

I suggest that you create an ImageStimulus object in the beginning of the OnInitialize() function of your modified StimulusPresentationTask, as it's done there in line 379-385, but without adding it to an association.
Set its PresentationMode to ShowHide, and call its Show() and Present() methods to display the image.

Best regards,
Juergen

doug.davies
Posts: 12
Joined: 09 Jun 2011, 13:07

Re: Background Image

Post by doug.davies » 06 Sep 2011, 20:09

Hi all -
I have attempted to implement the solution Juergen suggests here, but when I run the module there is no display from the background image. The module starts up and runs correctly, aside from this issue, and throws no error messages. In essence, the new parameter and the added code seem to have no effect.
I have added two parameters to the beginning of the file, one a switch/checkbox controlling whether the background image is displayed and the other a single entry matrix with the path to the background image.

Here is the code I have added to the beginning of the OnInitialize method. Can anyone suggest why the background image might not display? Thanks in advance.

Code: Select all

bool backgroundSwitch = (Parameter("BackgroundSwitch") == 1);
	if (backgroundSwitch && (Parameter("Background")(0,0)) != ""){
		
		int iconSizeModeNew = GUI::AspectRatioModes::AdjustHeight;
		GUI::Rect iconRectNew =
	   {
	     0.5,0.5,0.5,0.5
	   };
		ImageStimulus* background = new ImageStimulus(Display());
		background->SetFile((Parameter("Background")(0, 0)))
					.SetRenderingMode( GUI::RenderingMode::Opaque )
		            .SetAspectRatioMode( iconSizeModeNew )
		            .SetDisplayRect( iconRectNew );
		background->SetPresentationMode(VisualStimulus::ShowHide);
		background->Show();
		background->Present();
	}

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Re: Background Image

Post by mellinger » 07 Sep 2011, 06:43

int iconSizeModeNew = GUI::AspectRatioModes::AdjustHeight;
You need to set the aspect ratio mode to "AdjustBoth". The specified rectangle is empty, and requires resizing in both dimensions in order to be visible.

Regards,
Juergen

Locked

Who is online

Users browsing this forum: No registered users and 0 guests