Canvas questions to load images

David McFarlane mcfarla9 at msu.edu
Tue Sep 18 14:24:37 UTC 2012


Corona,

Well, I learned something here.  I never quite realized that 
Canvas.Copy always acts as though it has "Stretch" enabled, as 
indicated in the Canvas.Copy topic of the E-Basic Help:  "The copied 
area is resized if the source and destination rectangles are not the 
same size."  I did not believe this until a moment ago when I tested 
this with my own little demo program (policy:  *never* takes anyone's 
word for anything, *always* test for yourself).  Thank you for 
bringing that up.

So, if you want to crop a copied area instead of resizing it, you do 
that by cropping the source Rect, not the destination Rect.

Note that Canvas.Copy does, optionally, allow for other on-the-fly 
effects such as "transparent" colors and mirroring.

Also note that, as explained in the Rect topic, a Rect does *not* 
include its Right or Bottom borders, so you must make Right and 
Bottom one pixel more than your desired source and destination areas 
(this happens automatically if you calculate Right and Bottom by 
adding width and height to Left and Top, think about it) (and again, 
do not take anyone's word for this, construct your own demo programs 
to test this for yourself).

Finally, I agree with "FrankBank" in wondering why you go to all the 
trouble to use Canvas in the first place.  Depending on the 
requirements of the particular task, you might get the same 
performance benefits simply from judicious use of PreRelease.

-----
David McFarlane
E-Prime training 
online:  http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter:  @EPrimeMaster (https://twitter.com/EPrimeMaster)


At 9/17/2012 09:18 PM Monday, Corona wrote:
>Follow up question:
>
>Is there a substitute for stretch property in canvas?
>
>Thanks,
>Corona
>
>On Monday, September 17, 2012 6:13:45 PM UTC-4, Corona wrote:
>Thanks David.
>
>I have finally managed to load my images, with the script as follows:
>
>Dim myRect As Rect
>
>XRes = 1280
>YRes = 768
>
>'define source rect as full screen
>src.Left = 0
>src.Top = 0
>src.Right = Display.Xres
>src.Bottom = Display.Yres
>
>'define destination rect as top left quadrant
>dest.Left = 120
>dest.Top = 180
>dest.Right = Display.Xres + 424
>dest.Bottom = Display.Yres + 283
>
>'Canvas codes follows
>
>My question is, how do the images appear (without fully covering the 
>screen), given that my dest.Right and dest.Bottom variables are 
>greater than the
>set pixel co-oordinates in the E-Prime system?
>
>On Monday, September 17, 2012 5:05:20 PM UTC-4, McFarlane, David wrote:
>Corona,
>
>Addressing only point (2):  If you do that, then square images (e.g.,
>100 x 100) will not be square on your display (please do not take my
>word for this, measure it for yourself).  At least, that is what
>happened to us.
>
>Only after contacting PST Web Support did I learn that, with EP2, you
>are not restricted to the resolution options in the dropdown menu,
>you may manually enter any values you like there and as long as they
>are valid for your display hardware EP2 will use it.  Better yet,
>with EP2, set Display resolution to "Match desktop resolution at
>runtime", then set your desired display resolution in Windows, and
>EP2 will just use that.  Simple.
>
>Of course, this does not work for EP1, in which case you are sunk.
>
>-----
>David McFarlane
>E-Prime training
>online: 
><http://psychology.msu.edu/Workshops_Courses/eprime.aspx>http://psychology.msu.edu/Workshops_Courses/eprime.aspx 
>
>Twitter:  @EPrimeMaster 
>(<https://twitter.com/EPrimeMaster>https://twitter.com/EPrimeMaster)
>
>
>At 9/17/2012 01:13 PM Monday, Corona wrote:
> >Thank you all for your help so far. I have been reading a few posts
> >on resolving image dimension issues. Here is what I have done so far:
> >
> >1) My system resolution is 1280 x 800
> >
> >2) I went to e-prime->experiment->devices->display->edit->and
> >changed to 1280 x 768 (I do not have 800 as a drop down option).
> >
> >3) My images have uniform pixel dimensions of 424 x 283 (bmp images).
> >
> >4) I am using canvas object given the large number of images I have:
> >
> >After loading the offscreen canvas, my script (based on a previous
> >response to my question) is as shown below:
> >
> >xMargin = 120
> >yMargin = 120
> >
> >myRect.Left = xMargin
> >myRect.Right = xMargin + 424
> >myRect.Top = yMargin
> >myRect.Bottom = ymargin + 283
> >
> >However, this caused my images to be cropped. I played around with
> >the numbers for xMargin, but did not get any satisfactory results
> >(images are cropped on either length or width).
> >
> >Then, I resorted to trying this:
> >
> >XRes = 1280
> >YRes = 768
> >
> >'define source rect as full screen
> >src.Left = 120
> >src.Top = 120
> >src.Right = Display.XRes
> >src.Bottom = Display.YRes
> >
> >'define destination rect as top left quadrant
> >dest.Left = 120
> >dest.Top = 120
> >dest.Right = 120 + Display.XRes + 424
> >dest.Bottom = 120 + Display.YRes + 283
> >
> >This yielded better results, but my images are still cropped. What
> >am I missing here? I changed screen dimensions on e-prime to
> >approximately"match" my system's resolution, but still not getting
> >the results I desire.
> >
> >Thank you again for your input,
> >Corona
> >
> >On Sunday, September 16, 2012 2:18:01 PM UTC-4, Corona wrote:
> >Thank you. I had looked at the site link you've given, but it was
> >more a problem of running the validation tool that was failing
> >(although I do have an original Vista version). Apparently, the
> >error I encountered is quite common (or so, the Microsoft user
> >forums suggest). I however, found a roundabout way, which may be
> >useful for
> >others:
> ><<http://download.cnet.com/Help-Explorer-Viewer/3000-6675_4-1066666 
> 1.html>http://download.cnet.com/Help-Explorer-Viewer/3000-6675_4-10666661.html>http://download.cnet.com/Help-Explorer-Viewer/3000-6675_4-10666661.html 
>
> >. This software application works as a reader for .hlp files.
> >
> >Thank you for your suggestions. Now that I have the E-Basic help
> >showing up(or visible), I can at least look it up.
> >
> >Corona.
> >
> >On Sunday, September 16, 2012 1:43:51 PM UTC-4, J wrote:
> >This should help with viewing help files in Windows Vista (as a
> >novice e-basic programmer, I have to say that access to E-Basic Help
> >is essential).
> >
> ><<http://support.microsoft.com/kb/917607>http://support.microsoft.c 
> om/kb/917607>http://support.microsoft.com/kb/917607
> >
> >J
> >
> >On 9/16/2012 11:36 AM, Corona wrote:
> >>Thank you. I do not have access to the e-prime basic help, due to
> >>running a Windows-Vista, 64-bit system.  .hlp files are no longer
> >>recognized by Vista-32. I tried installing a tool that allows .hlp
> >>files to be read, but it somehow failing. Is there a workaround to
> >>this, so I can view the e-prime basic files?
> >>
> >>Thanks,
> >>Corona
> >>
> >>On Sunday, September 16, 2012 11:39:37 AM UTC-4, Peter Quain wrote:
> >>
> >>I cannot think of why might else you would crave this knowledge.
> >>The documention, topic Canvas, will help understanding this code,
> >>you will need to if it is Canvas that you wish to use
> >>
> >>At 01:31 AM 17/09/2012, you wrote:
> >>>Thank you Alphonse, for the quick reply. More for the purpose of
> >>>understanding the code, than anything else, why do you
> >>>repeat  cnvs.Copy offScreenCnvs, myRect, myrect (with myrect
> >>>twice)? More specifically, how is this understood by e-prime?
> >>>Also, I am guessing I do not have to include a slideobject?
> >>>
> >>>
> >>>
> >>>On Sunday, September 16, 2012 10:59:26 AM UTC-4, alphonse wrote:
> >>>-----------------------------------------------
> >>>'Prepare stimulus offscreen
> >>>offScreenCnvs.LoadImage stim
> >>>'Define the copy area
> >>>Dim myRect As Rect
> >>>myRect.Left = xMargin
> >>>myRect.Right = xMargin + 60
> >>>myRect.Top = yMargin
> >>>myRect.Bottom = yMargin + 60
> >>>'Copy prepared stimulus to screen
> >>>cnvs.Copy offScreenCnvs, myRect, myRect
> >>>----------------------------------------------------------------- 
> ---------
> >>>At 12:39 AM 17/09/2012, you wrote:
> >>>>I am currently running a dot probe task with visual paired
> >>>>stimuli (positive, negative). I have a two fold question
> >>>>pertaining to this task:
> >>>>1) I have about 60 images in one of my trialprocs, and was
> >>>>therefore advised to use the canvas option to preload images. I
> >>>>have had little success with using this object, particularly
> >>>>because I do not entirely understand the concepts of off-screen
> >>>>and on-screen canvas. I have managed to write a small script with
> >>>>help from the references guides posted on the e-prime website (as
> >>>>well as forums), but am stuck when it comes to the following statement:
> >>>>1.      When preparing the trial:
> >>>>
> >>>>targetCanvas.LoadImage stim
> >>>>
> >>>>Image is loaded to the top left corner. We need to define 2 Rect
> >>>>Objects: StimLoadRect and StimRect (see Rect object in the
> >>>>E-Basic Help), both the size of the images to-be-loaded, but the
> >>>>StimRect at the (Left,Right, Top,Bottom) coordinates where the
> >>>>stimulus will be displayed. When we copy the image from the
> >>>>offline canvas to the online canvas, we will copy from
> >>>>StimLoadRect to StimRect.
> >>>>
> >>>>2.      To run the stimulus:
> >>>>
> >>>>Display.WaitForVerticalBlank
> >>>>c.setAttrib "StimOnset", clock.read
> >>>>cnvs.copy targetCanvas, stimLoadRect, stimRect
> >>>>sleep(stimDuration)
> >>>>Display.WaitForVerticalBlank
> >>>>Cnvs.clear ' or something else that erases the stimulus, can be
> >>>>done in the following trial
> >>>>
> >>>>
> >>>>Bolded lines: How do I create a stimLoadRect and stimRect image,
> >>>>a is asked for? (I did find a script for creating a rect object,
> >>>>but am unsure of how to specify dimensions).
> >>>>I assume that pre-defining images and their locations, means I do
> >>>>not have to specify them as a SlideObject? (I am guessing I am
> >>>>completely wrong here - please feel free to correct me) . I would
> >>>>also assume that the stimDuration, must be defined as an attribute?
> >>>>
> >>>>Assuming I do not have to go through this convoluted path, I have
> >>>>another question. If I could pre-load using the SlideImage and
> >>>>ImageDisplay options, I am not sure how to specify the
> >>>>co-ordinates of where I want my image to be in the properties
> >>>>section. I know this appears elementary, but the actual size of
> >>>>the images are 424 X 283, but when running, part of the images
> >>>>are cut off. When I looked at the properties of my slide object,
> >>>>I had set the width at 25% . I assumed this was the co-ordinate
> >>>>location in relation to the actual screen size. Guessing that
> >>>>this was an error on my part, I reset the width to 100%, but that
> >>>>meant that when I looked at the slideobject (with the dotted
> >>>>grid), one image seemed to complete cover the other image. How do
> >>>>I fit both images, and make sure their dimensions remain the same?
> >>>>I apologize for this rant. I only recently switched to e-prime
> >>>>from using Inquisit, and am still trying to get a hang of this 
> software tool.
> >>>>Thanks a ton for your reply,
> >>>>Corona

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



More information about the Eprime mailing list