World: r4wp
[#Red] Red language group
older newer | first last |
james_nak 27-Jun-2013 [8858x2] | Doc, I must be in some other world. Where is red/bridges? |
I checked the pastebin link and saw the code. | |
Kaj 27-Jun-2013 [8860x2] | It's in the dyn-lib-emitter branch. I guess you were looking in master? |
https://github.com/dockimbel/Red/tree/dyn-lib-emitter/red/bridges/android/samples/eval | |
james_nak 27-Jun-2013 [8862] | Kaj, thanks. Yes, I was in master! Perfect. |
Kaj 27-Jun-2013 [8863] | Almost the same as another world ;-) |
james_nak 27-Jun-2013 [8864x3] | When you're lost it is exactly the same. The problem with me is that I come in and out of these conversations and so end up not building on top of previous knowledge. Every trip into red-landia is a new one :-) |
While I am at it, I'm on the dyn-lib-emitter page, is there something I click on to download the entire dyn-lib folder? | |
Nevermind. I just created an account and now see the zip button. | |
Kaj 27-Jun-2013 [8867] | I thought it worked without an account. But I haven't been logged out for a long time |
james_nak 27-Jun-2013 [8868] | I don't know if I am using it correctly but I attempted to run the build.r file (w/o any arguments...I think it builds the "eval.red"). I end up with: Signing apk... 'jarsigner' is not recognized as an internal or external command, operable program or batch file. Aligning apk... Unable to open 'builds\eval-signed.apk' as zip archive |
Kaj 27-Jun-2013 [8869x2] | It should have downloaded the jarsigner and other tools |
Do you have a JDK installed? | |
james_nak 27-Jun-2013 [8871] | Interesting, the lines for downloading that are commented out. I will try it again. I do have the JDK installed as I was doing some driod app stuff a while back. |
Kaj 27-Jun-2013 [8872x2] | Seems a mistake |
Wonder how it worked for Petr | |
james_nak 27-Jun-2013 [8874] | Getting closer. I now have jarsigner but the cmd expected to see it in the root dir. So I just placed jarsigner there along with the jli.dll. That may not be a good idea because it seems to do its thing but finally dies with: Signing apk... Error: Could not find or load main class sun.security.tools.JarSigner Aligning apk... Unable to open 'builds\eval-signed.apk' as zip archive |
Kaj 27-Jun-2013 [8875] | Looks like Doc and Petr had jarsigner already installed with their tool suite |
james_nak 27-Jun-2013 [8876] | At this point I am stuck on the sun.security.tools.JarSigner file issue. |
Bo 27-Jun-2013 [8877] | OK. Next enigma about Red/System that I ran into. Consider the two following sets of code and output. Why are they different? Code 1: im1: as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) print-line as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) Output 1: ... 96 99 107 111 105 104 100 99 100 98 Code 2: im1: as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) print-line im1 Output 2: ... 4260192 4260451 4260203 4260207 4259945 4259944 4259940 4260451 4260196 4260194 |
Kaj 27-Jun-2013 [8878] | The example is not complete. How do you get more than one value? |
Bo 27-Jun-2013 [8879x3] | This is a loop that processes raw binary image data. 'r, 'g, and 'b are incremented through an 'until loop until the data is all consumed. |
But what is troubling to me is that print-line im1 is not equal to print-line as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) | |
They should be equivalent. | |
Kaj 27-Jun-2013 [8882x2] | It could be a Red/System bug, or it could be a result of the code you're not showing. Can't tell |
Are you doing this on the Raspberry? Doc recently made fixes to the ARM code emitter. It was less mature than the x86 emitter | |
Bo 27-Jun-2013 [8884x2] | I am running this on Windows currently. XP 32-bit. Here's the complete code: #include #../C-library/ANSI.reds img1: as-binary 0 size1: 0 img1: read-file-binary "img1.bin" :size1 i: 0 r: 0 g: 0 b: 0 im1: 0 until [ r: i + 2 g: i + 3 b: i + 4 im1: as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) print-line im1 ;as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) i: i + 4 i >= size1 ] |
If I change the line print-line im1 ;as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) to print-line as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3)) I get the expected output. | |
PeterWood 27-Jun-2013 [8886x2] | It could be caused by differences in the auto-casting between a simple assignment and a call to print-line. Being conservative I would have written: im1: (((as integer img1/r ) / 3) + (as integer img1/g) / 3) + (as integer img1/b) / 3) |
plus one more ) at the end :-) | |
Bo 27-Jun-2013 [8888x3] | I already tried that and got an error from the compiler saying that there was an unnecessary cast from integer to integer. |
*** Warning: type casting from integer! to integer! is not necessary | |
It would then exit. | |
PeterWood 27-Jun-2013 [8891] | What type is img1/r ? |
Bo 27-Jun-2013 [8892x2] | img1 is binary (or byte!) I suppose. |
img1 is a pointer to an array of those bytes, I should have said. | |
Kaj 27-Jun-2013 [8894] | The addition can't result in more than a byte, so it should be no problem to do it with bytes |
Bo 27-Jun-2013 [8895] | I just can't see how the output I'm seeing is not a bug. I was hoping you could explain it. |
PeterWood 27-Jun-2013 [8896] | But it seems as the compiler thinks that img/r is an integer! |
Kaj 27-Jun-2013 [8897] | Yes, it looks like a bug |
Bo 27-Jun-2013 [8898x3] | Agreed. |
Could it be a problem that I'm type casting im1 to an integer in the line im: 0 ?? | |
Forget it, that can't be the problem. | |
Kaj 27-Jun-2013 [8901] | That's not a cast, just an assignment |
Bo 27-Jun-2013 [8902] | I thought maybe the type was cast by the value you assigned to it. |
Kaj 27-Jun-2013 [8903] | Declared, but not cast, because it wasn't known yet |
Bo 27-Jun-2013 [8904] | The problem I'm trying to solve is to convert two seperate images to grayscale and then compare the pixels in each image to each other to look for big variations in contrast between the pixels. |
Kaj 27-Jun-2013 [8905] | You did upgrade your Red/System, didn't you? |
Bo 27-Jun-2013 [8906x2] | If I can't assign the answer of a calculation to a word and then use that word in other calculations, then it's a roadblock that I'm not sure how to overcome. |
Yes, I updated Red/System yesterday from Github. | |
older newer | first last |