Re: Setting Pixels

2004-12-28 Thread Scott Rossi
Recently, Gordon Webster wrote:

> Here is my question - Dan's book describes the use of
> the 'mouseColor' handler to get the color value of the
> pixel that is below the mouse - is there any way in
> rev, to set the value of an individual pixel?

See Ken Ray's useful explanation here:

  http://sonsothunder.com/devres/metacard/tips/imag003.htm

This explains how imageData, alphaData and maskData work.  It may be a bit
overwhelming at first, but there's some sample code included to get you
started.

(I just used this last night -- thank Ken!)

Regards,

Scott Rossi
Creative Director
Tactile Media, Development & Design
-
E: [EMAIL PROTECTED]
W: http://www.tactilemedia.com

___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


Setting Pixels

2004-12-28 Thread Gordon Webster
Dear Revolutionaries

I hope you are all having a happy holiday. Mine
started really well as the copy of Dan Shafer's book I
had ordered, arrived the day I was leaving for the
holidays :-) I have thoroughly enjoyed reading it
these last few days and recommend it whole-heartedly
to any fellow rev newbies (it's available on the
runrev website) - so when do the next two volumes come
out?

Here is my question - Dan's book describes the use of
the 'mouseColor' handler to get the color value of the
pixel that is below the mouse - is there any way in
rev, to set the value of an individual pixel?

Best

Gordon


=
:: Gordon Webster ::
___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Setting Pixels - Clarification

2003-02-01 Thread paolo mazza
Ken wrote:

This is something that as you identified is too slow to be done in 
regular
Transcript. You need the help of an external to do the processing of 
the
imageData for you. You might want to check out Chipp Walters' image 
tools
at:

http://www.altuit.com/webs/altuit2/RunRev/Downloads.htm

There's image compositing and convolution matrix utilities there that 
use an
external for speed.


There is an external for Windows (ddl). How can I get en external for 
MAC to speed up the process?

Best regards,

Paolo Mazza

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Setting Pixels - Any geeks out there?

2003-01-31 Thread Robert J Warren \(Howsoft.com\)
For those of you who are interested in graphics, I DO suggest you try
Monte's custom paint tool for simply drawing squiggly lines with the mouse.
In terms of coding, and since Monte has proved to us all that he is quite
good at this kind of thing, I think that this routine is probably about as
efficient as it can be. Yet on my Pentium II (Windows ME), the result is not
very good, certainly not as good as it would be in VB. The mouse draws a
broken rather than continuous line, even when you move it slowly.

So contradict me if I am wrong:

The development of a procedure for direct access to the image's pixel data
(rather than having instructions like 'put the imageData of image "bmw.bmp"
into iData, set the imageData of image "bmw.bmp" to iData', etc.) would
probably help a lot.
But as I said, it would take a real bright spark (someone with internal
knowledge of the Transcript engine) to come up with such a solution.
However, they did it in VB...

ARE THERE ANY GEEKS OUT THERE?

When the RunRev team get their heads above water, I would also like to know
what they think about this issue.

Here's Monte's routine again:

-Button script

on mouseUp
  InitialiseImageData
  InitialisePaintColor
end mouseUp

-Card script

local lImageData,lPaintColor,lMouseDown

on InitialiseImageData
  put the imageData of image 1 into lImageData
end InitialiseImageData

on InitialisePaintColor
  put binaryEncode("",0,0,255,0) into lPaintColor
end InitialisePaintColor

on mouseMove x,y
  if lMouseDown then
if word 1 of the target is "image" then
  set the lockCursor to true
  set the cursor to cross
  put (x-the left of image 1)*4+(y- the top of image 1)*(the width of
image 1*4) into x
  put lPaintColor into char x-3 to x of lImageData
  set the imageData of image 1 to lImageData
end if
  else
pass mouseMove
  end if
end mouseMove

on mouseDown
  put true into lMouseDown
end mouseDown

on mouseUp
  put false into lMouseDown
end mouseUp

on mouseRelease
  put false into lMouseDown
end mouseRelease




___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Setting Pixels - More answers to suggestions

2003-01-30 Thread Sarah
Hi Robert,

Yes, an XCMD is like a DLL only for Macs. It means external command 
(there are also XFCNs - external functions). I have a script that 
converts RGB <-> HSV if you are interested. As Monte and others have 
shown, scripting in different ways can dramatically alter the speed of 
execution. Perhaps my script might be as fast as your DLL :-) If you 
would like me to send it, email me off-list.

Cheers,
Sarah

On Thursday, January 30, 2003, at 02:17  pm, Robert J Warren 
((Howsoft.com)) wrote:

Thanks, and sorry Chipp, I am not only new to Transcript but I also 
know
nothing at all about Macs. I presume that an XCMD is the Mac version 
of a
Windows DLL (?) I am sure that it would help, but I am not sure to what
degree. I have only ever written one DLL in my life which is for the 
said
eraser program in VB (due to be launched soon). It converts RGB to HSL 
and
v.v. By doing the calculations in a DLL rather than in the program the
saving was about 15%. Although this 15% was crucial in the eraser 
routine I
wrote, it was generally a disappointment: I expected a much bigger 
saving.


___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



RE: Setting Pixels - More answers to suggestions

2003-01-30 Thread Monte Goulding

Hi All

I never read the original problem but I just made a custom paint tool with
this:

-- button script

on mouseUp
  InitialiseImageData
  InitialisePaintColor
end mouseUp

-- card script

local lImageData,lPaintColor,lMouseDown

on InitialiseImageData
  put the imageData of image 1 into lImageData
end InitialiseImageData

on InitialisePaintColor
  put binaryEncode("",0,0,255,0) into lPaintColor
end InitialisePaintColor

on mouseMove x,y
  if lMouseDown then
if word 1 of the target is "image" then
  set the lockCursor to true
  set the cursor to cross
  put (x-the left of image 1)*4+(y- the top of image 1)*(the width of
image 1*4) into x
  put lPaintColor into char x-3 to x of lImageData
  set the imageData of image 1 to lImageData
end if
  else
pass mouseMove
  end if
end mouseMove

on mouseDown
  put true into lMouseDown
end mouseDown

on mouseUp
  put false into lMouseDown
end mouseUp

on mouseRelease
  put false into lMouseDown
end mouseRelease

Hope you like drawing squigly lines ;-)

Monte

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Setting Pixels - Congratulations Monte!

2003-01-30 Thread Dave LeYanna
GREAT JOB folks!

djl

At 02:04 PM 1/30/03 -0200, you wrote:

Monte has beat us ALL to the punch! Making his recommended alterations to
the little test routine shows us that there is no substitute for a good
knowledge of the timing aspects of the Transcript language. The timings on
my machine are similar to his. Thanks Monte!

So now I can apply all that has been recommended and try a real "eraser"
test. Who knows, it might be agile enough to implement in "pure" Transcript.
That said, of course the problem becomes analogous to the one I had in VB.
"Pure" VB worked more or less OK, but some bright spark eventually found a
way of accessing the image data directly, so that procedures like -

put the imageData of image "bmw.bmp" into iData
set the imageData of image "bmw.bmp" to iData

- became unnecessary. Consequently, the advice "DON'T use VB for graphics"
became far less true, although of course it is a long way from being an
instrument for constructing games. To achieve something similar in
Transcript might also be an advantage in terms of speed leading to the
statement "You CAN use Transcript for graphics (but not for games?)", but it
would take someone who has a really deep knowledge of the internal workings
of the system to come up with such an "image bitmap pointer" procedure
(someone from the RunRev team or a geek working at the university?).

Anyway, I am very happy for now. Many thanks to all who have contributed to
the solution of setting pixels. I feel inspired enough by your obvious
interest to actually go off and learn more about what I now consider to be a
"viable" new language.



___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


==
||   Dave LeYanna ||
||   Director IS   ||
||   Right to Life of Michigan||
==

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Setting Pixels - Congratulations Monte!

2003-01-30 Thread Robert J Warren \(Howsoft.com\)
Monte has beat us ALL to the punch! Making his recommended alterations to
the little test routine shows us that there is no substitute for a good
knowledge of the timing aspects of the Transcript language. The timings on
my machine are similar to his. Thanks Monte!

So now I can apply all that has been recommended and try a real "eraser"
test. Who knows, it might be agile enough to implement in "pure" Transcript.
That said, of course the problem becomes analogous to the one I had in VB.
"Pure" VB worked more or less OK, but some bright spark eventually found a
way of accessing the image data directly, so that procedures like -

put the imageData of image "bmw.bmp" into iData
set the imageData of image "bmw.bmp" to iData

- became unnecessary. Consequently, the advice "DON'T use VB for graphics"
became far less true, although of course it is a long way from being an
instrument for constructing games. To achieve something similar in
Transcript might also be an advantage in terms of speed leading to the
statement "You CAN use Transcript for graphics (but not for games?)", but it
would take someone who has a really deep knowledge of the internal workings
of the system to come up with such an "image bitmap pointer" procedure
(someone from the RunRev team or a geek working at the university?).

Anyway, I am very happy for now. Many thanks to all who have contributed to
the solution of setting pixels. I feel inspired enough by your obvious
interest to actually go off and learn more about what I now consider to be a
"viable" new language.



___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



RE: Setting Pixels - More answers to suggestions

2003-01-29 Thread Monte Goulding

>
> I think you can speed this up just a litle bit on the
> first run by changing:
>   if tData = "" then
> put char 1601 to -1 of the imageData of image 1 \
>into tData
>   end if
> This ought to be slightly faster as the engine doesn't
> have to resize the tData variable again, nor push its
> contents forwards upon deleting from the front.
>

Yep

Back down to 0.162

I think what I'd do would be to initialise the data when the image was first
opened. Say openStack?

Monte

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Setting Pixels - More answers to suggestions

2003-01-29 Thread Robert J Warren \(Howsoft.com\)
From Dar Scott:

http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Setting Pixels - Answers to Suggestions

2003-01-29 Thread Dar Scott

On Wednesday, January 29, 2003, at 11:39 AM, Robert J Warren 
((Howsoft.com)) wrote:

According to the method outlined by Ken Ray in his article, I tried a 
test
replacement of a mere 400 pixels, and this took various seconds! Part 
of the
trouble is that Transcript does not appear to have instructions for 
simply
reading or replacing individual pixels, which might alleviate the 
problem to
some degree. However, ironically, as I have found out in VB, this is 
not the
best solution. For maximum speed you have to process the image's pixel 
data
directly. Putting even part of the pixel data into a variable or array 
for
processing slows the whole thing down too much, and don't forget that 
quite
complex mathematical calculations have to be performed on each pixel, 
which
if done correctly can also take up considerable time.

I need to read Ken Ray's article.  I suspect his examples are designed 
for clarity rather than efficiency.

Char chunking for getting data is fast.  Char chunking for replacing 
data can be slow.  Specifically, ...

Assume operations are on a copy of the image.  Char chunking for 
getting pixel data is fast.  However, char chunking for replacing pixel 
data goes up with the size of the image.  (It might be nice if 
replacement noticed the size was the same and did the replacement in 
place, but alas, that doesn't seem to be the case.)  It is thus better 
to replace the entire pixel rather than each individual pixel component 
in an image of nontrivial size.  And, as mentioned in #3 below, it is 
better to replace sub-rows than pixels.

Here are a couple things to try.

1
There may be places in which it is better to refer to the image data 
(or sub-image) by reference and refer to parts of it by that and char 
positions.

2
There may be ways you can avoid repeating row-column calculations.  Use 
a function to create a char pointer from row and column and use that as 
you need.  For example, you don't need to calculate the position for 
both the read and the write.

3
After you are happy with your method, change the atomic operation from 
pixel orientation to sub-row orientation.  This handler should work on 
a sequence of pixels (as specified by char positions) and need not know 
anything about the size of the image.  That is, you don't have to do a 
row-column calculation for each pixel and replacement is directly by 
char pointer.  If you need a few pixel oriented operators but don't use 
them often, build them out of the sub-row operators.  Remember, build 
up your new sub-row, then replace it in one operation.  If you prefer a 
functional style, you can use a string function to operate on a an 
sequence of pixels and return a string of pixels and then put things 
together at the higher level.  With that optimization, the char 
chunking replacement will be less of a hit; you will be doing only one 
replacement per row under your wand.  It the image can be lots taller 
than the wand, you may want to select out the applicable rows, make the 
transformation, then then put it all back together.

Dar Scott

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Setting Pixels - Answers to Suggestions

2003-01-29 Thread Chipp Walters
Bob,

I've thought some about this problem. If you can't use the direct editing
mode (choose pencil, eraser, etc..), then it will probably be too slow.

Perhaps a DLL or XCMD would do the trick...

-Chipp

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Setting Pixels - Answers to Suggestions

2003-01-29 Thread Robert J Warren \(Howsoft.com\)
First of all, I would like to thank the various members of the list who have
given me a number of interesting suggestions in relation to my "pixels
problem". All info has been gratefully received. Thanks also to those who
have given me advice in relation to the originally stated (but
oversimplified) drawing problem. I'm learning a lot!

In response to -
http://www.altuit.com/webs/altuit2/RunRev/Downloads.htm

http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Setting Pixels

2003-01-29 Thread Klaus Major
Hi Jim,


..
The good people at RR have posted a demo stack in the "Education" page 
on the RunRev site:
http://www.runrev.com/revolution/education/usercontributions.html

Check the User Contributions. This is intended primarily for an 
elementary course in programing in
Transcript  and Turtle Graphics for science students, but it may  also 
work for you.

Jim Hurley

i also would like to take a look at "turtles".
Heard it very often in the past, but still have no idea what i means.

Unfortunately i cannot get it work.

A look at your scripts showed me the reason.

You use lots of reserved word in your handlers, be it as a handler name
("left", "right", "home" etc...) or names of variables ("num" as the 
most obvious example).

I would really appreciate if you could take a look again and change 
your stack.


Thanks a lot in advance.


Regards

Klaus Major
[EMAIL PROTECTED]

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Setting Pixels

2003-01-29 Thread Chipp Walters
Hi Bob,

> From the examples, this seems to mean in practice that if I want 
> to change a
> single pixel in an image I need to read the whole image bitmap into a
> variable, change the pixel in the variable, and then copy the 
> whole variable
> contents back into the image.

Much easier to edit the image via script with a pencil.

on mouseUp
  select img 1
  choose pencil
  drag from topLeft of img 1 to botRight of img 1
  choose browse
end mouseUp

This could easily be set up to modify a single pixel in an image..

for instance a button with:

on mouseUp
  changeThisPixel 3,7,"test","red"
end mouseUp

on changeThisPixel pDeltaX,pDeltaY,pImg,pColor
  select img pImg
  choose pencil
  set the penColor to pColor
  put left of img pImg + pDeltaX into tXpixel
  put top of img pImg + pDeltaY into tYpixel
  click at tXpixel,tYpixel
  choose browse
end changeThisPixel

it's instant on my machine

-Chipp
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



RE: Setting Pixels (for Jim Hurley)

2003-01-29 Thread Chipp Walters
Jim, tried to send this offlist,
but was blocked by:
dnsbl.njabl.org

Hey Jim!

Nice stack! Though I'm having a bit of a problem working with it

I opened it in RR1.5 on a PC and it doesn't want to work.
I see you have many variables called 'num' in the stack script. 'num' is a
reserverd transcript term, so it won't work (at least not on my PC:-)

I'd like to play with your stack. Let me know if you get around to fixing
it! Thanks for supporting RR.

best,

Chipp

> Robert,
> 
> Just to add a bit to Scott's good advice:
> 
> If you would like some tools to facilitate this kind of  drawing, the 
> ideal is Turtle Graphics. 
> 
> Jim Hurley

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Setting Pixels - Clarification

2003-01-28 Thread Dar Scott

On Tuesday, January 28, 2003, at 07:24 PM, Robert J Warren 
((Howsoft.com)) wrote:

From the examples, this seems to mean in practice that if I want to 
change a
single pixel in an image I need to read the whole image bitmap into a
variable, change the pixel in the variable, and then copy the whole 
variable
contents back into the image.

Surely not! This is an incredibly slow process.

How long does it take to copy an image?

Maybe you can cut that in half by doing the "read the whole image 
bitmap" only once.

Dar Scott

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Setting Pixels

2003-01-28 Thread Robert J Warren \(Howsoft.com\)
Dear Jim,
Many thanks for the very interesting advice on the "setting pixels" problem.
I'll certainly follow it up.

Regards,
Bob Warren


___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Setting Pixels - Clarification

2003-01-28 Thread Ken Ray
Robert,

This is something that as you identified is too slow to be done in regular
Transcript. You need the help of an external to do the processing of the
imageData for you. You might want to check out Chipp Walters' image tools
at:

http://www.altuit.com/webs/altuit2/RunRev/Downloads.htm

There's image compositing and convolution matrix utilities there that use an
external for speed.

I hope it works for you,

Ken Ray
Sons of Thunder Software
Email: [EMAIL PROTECTED]
Web Site: http://www.sonsothunder.com/

- Original Message -
From: "Robert J Warren (Howsoft.com)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 28, 2003 8:24 PM
Subject: Setting Pixels - Clarification


> Many thanks to Scott Rossi for the tip, which as a Rev beginner I am
> grateful for. However, I overdid it a little in trying to state my
objective
> simply. So I'll repeat the relevant part of my problem and try to explain
my
> aim more carefully.
>
> As I gather from Ken Ray's very useful article "Understanding ImageData,
> MaskData and AlphaData", "...you don't set SPECIFIC PARTS of imageData...,
> you set  these properties as a whole."
>
> >From the examples, this seems to mean in practice that if I want to
change a
> single pixel in an image I need to read the whole image bitmap into a
> variable, change the pixel in the variable, and then copy the whole
variable
> contents back into the image.
>
> Surely not! This is an incredibly slow process. Can anyone tell me of a
> workaround? Or if there is no solution in RunRev #1, will this be fixed in
> #2?
>
> What eventually I would like to do is something like this (but this is
only
> any example). Suppose I am moving the mouse pointer in the form of an
eraser
> (i.e. a square of certain dimensions) over a photo. Wherever the eraser
> passes, the colours change to a given different hue. So what I need is to
be
> able to extract the pixels under the eraser, convert them to HSL, adjust
the
> hue, convert them back to RGB, and then replace the pixels in the photo in
> the required position under the eraser.
>
> Using a bitmap pointer technique I manage to achieve this at appropriate
> speed in VB by accessing the image bitmap directly, without having to copy
> the whole image into a variable which would slow down the process too
much.
>
>
> ___
> use-revolution mailing list
> [EMAIL PROTECTED]
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Setting Pixels

2003-01-28 Thread Jim Hurley

Recently, "Robert J Warren (Howsoft.com)"  wrote:


 All I want to do is something which is as easy as falling off a log in VB. I
 want to move the mouse around a window (over an image perhaps, but not
 necessarily) and to draw a line of pixels as I go - i.e. construct a very

 > primitive drawing program. I would be grateful if anyone could help.

Sounds like you could simply use the paint tools and an image object
overlaying whatever you want to draw on.  See the docs under choosing tools
("choose" command) and:
- pencil
- brush
- spray can
- bucket

Alternatively, you could use draw graphics, using the curve tool for
free-form drawing, or primitive shapes and polygons, but this can create
multiple objects, depending on how you implement it.

Hopefully there's something here you can use.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design



Robert,

Just to add a bit to Scott's good advice:

If you would like some tools to facilitate this kind of  drawing, the 
ideal is Turtle Graphics. You can control the turtle (drawing cursor) 
with such simple commands as:

Relative tools (independent of a coordinate system): Forward,Back, 
Left, Right, setHeading, etc.
Absolute tools (coordinate based):  setXY,  incrementXY, 
xyCoordinates(), xCor() etc. .


The good people at RR have posted a demo stack in the "Education" 
page on the RunRev site:

http://www.runrev.com/revolution/education/usercontributions.html

Check the User Contributions. This is intended primarily for an 
elementary course in programing in  Transcript  and Turtle Graphics 
for science students, but it may  also work for you.

Jim Hurley
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Setting Pixels

2003-01-28 Thread Scott Rossi
Recently, "Robert J Warren (Howsoft.com)"  wrote:

> All I want to do is something which is as easy as falling off a log in VB. I
> want to move the mouse around a window (over an image perhaps, but not
> necessarily) and to draw a line of pixels as I go - i.e. construct a very
> primitive drawing program. I would be grateful if anyone could help.

Sounds like you could simply use the paint tools and an image object
overlaying whatever you want to draw on.  See the docs under choosing tools
("choose" command) and:
- pencil
- brush
- spray can
- bucket

Alternatively, you could use draw graphics, using the curve tool for
free-form drawing, or primitive shapes and polygons, but this can create
multiple objects, depending on how you implement it.

Hopefully there's something here you can use.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-
E: [EMAIL PROTECTED]
W: http://www.tactilemedia.com

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution



Setting Pixels

2003-01-28 Thread Robert J Warren \(Howsoft.com\)
As I gather from Ken Ray's very useful article "Understanding ImageData,
MaskData and AlphaData", "...you don't set SPECIFIC PARTS of imageData...,
you set  these properties as a whole."

>From the examples, this seems to mean in practice that if I want to change a
single pixel in an image I need to read the whole image bitmap into a
variable, change the pixel in the variable, and then copy the whole variable
contents back into the image.

Surely not! This is an incredibly slow process. Can anyone tell me of a
workaround? Or if there is no solution in RunRev #1, will this be fixed in
#2?

All I want to do is something which is as easy as falling off a log in VB. I
want to move the mouse around a window (over an image perhaps, but not
necessarily) and to draw a line of pixels as I go - i.e. construct a very
primitive drawing program. I would be grateful if anyone could help.

Bob Warren


___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution