Draw bitmaps pixel by pixel
Tobias
tobias.fw at gmail.com
Thu Jun 17 09:49:42 UTC 2010
Thanks a lot for your detailed help. I am wondering how to implement
that code in my program. For now, I have a line calling for a certain
mask (which is always the same):
if c.getattrib("TargPos") = (i-1) then CueDisplay_SlideImage.Filename
= "mask.bmp"
So instead of this mask.bmp I would have need of the randomly
generated bitmap. I am not quite sure how to implement your code at
this place.
Thanks a lot in advance,
Tobias
On Jun 16, 6:36 pm, Michiel Spape <Michiel.Sp... at nottingham.ac.uk>
wrote:
> Hi,
> Drawing things pixel by pixel is quite easily implemented, given you know enough about programming (I seem to remember you do) - drawing bmp's pixel for pixel is more difficult, I expect (since A: you'd have to randomise pixels B: fill a file with it, then C: draw the file, whereas just doing the whole randomising in canvas saves step B and C). I think I even have something:
>
> Dim canvasmask as Mask
> Dim cnvs as Canvas
>
> Sub buildMask (masksize as integer, nCircles as integer, circlesize as integer)
> dim functiondur as long
> functiondur = clock.read
> dim cCircle as integer
> dim onetothree as integer
> dim ppoint as point
> for cCircle = 1 to nCircles
> onetothree = random (1,3)
> if onetothree = 1 then cnvsmask.FillColor = CColor("black")
> if onetothree = 2 then cnvsmask.FillColor = CColor("white")
> if onetothree = 3 then cnvsmask.FillColor = CColor("gray")
> cnvsmask.Circle random (display.xres / 2 - masksize / 2, display.xres / 2 + masksize / 2), random (display.yres / 2 - masksize / 2, display.yres / 2 + masksize / 2), circlesize / 2
> next cCircle
> debug.print "Mask took " & (clock.read - functiondur) & " ms to build"
> End Sub
>
> Sub drawmask (masksize as integer)
> dim midrect as rect
> midRect.Left = display.xres / 2 - masksize/2
> midRect.Right = display.xres / 2 + masksize/2
> midRect.Top = display.yres / 2 - masksize/2
> midRect.Bottom = display.yres / 2 + masksize /2
> cnvs.copy cnvsmask, midrect, midrect
> End Sub
>
> ... I think that should work. Anyway, dump the whole thing into your userscript, then use the following in an inline to A: build the mask (might take some time, hence the debugging script), B: show the mask (it's useful to do this separately for timing issues)
>
> 'probably do this at the beginning of the trial
> buildMask 100, 50, 10 'draws 50 circles of size 10 in a mask of size 100 (all pixels)
>
> 'do this when you want to show stuff
> Display.waitforverticalblank 'for sync issues, not sure about exact syntax.
> Drawmask 100
>
> ...of course, my code here was mainly written (and subsequently abolished) for shape-based (circle) masking. More effective code can be written if you just want to do pixel-by-pixel colouring. I imagine you get the picture.
>
> Cheers,
> Mich
>
> Michiel Spapé
> Research Fellow
> Perception & Action group
> University of Nottingham
> School of Psychology
>
> -----Original Message-----
> From: e-prime at googlegroups.com [mailto:e-prime at googlegroups.com] On Behalf Of Tobias
> Sent: 16 June 2010 12:15
> To: E-Prime
> Subject: Draw bitmaps pixel by pixel
>
> Hej together,
>
> I want to program a random mask for a visual attention experiment. The
> idea is, that the mask should be randomly created each trial because
> there are some hints that subjects "learn" to ignore a mask if it is
> repeatedly used. So what I think of is a white noise or something. Is
> there a way in E-Prime to create bitmaps pixel by pixel with an
> inline?
>
> Cheers,
> Tobias
>
> --
> 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 this group athttp://groups.google.com/group/e-prime?hl=en.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
--
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 this group at http://groups.google.com/group/e-prime?hl=en.
More information about the Eprime
mailing list