Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: do %image.png

From: ryanc:iesco-dms at: 14-Nov-2001 12:21

Should be even easier than that. Just insert something like this into it... REBOL[] confirm "This is a test." halt Just make sure you have the code enveloped in linefeeds. REBOL was designed to do this already. --Ryan Jason Cunliffe wrote:
> do %image.png > > My objective is to implement a roundtrip toolkit with /Core and /View > interfaces for embedding, extracting and running REBOL scripts embedded in > images. Then the real fun can begin! > > I have made a little progess: > A tiny hardcoded test is now working :-) > > buddha.png is a PNG image file with a REBOL script embedded in it. > http://www.postcardscience/rebol/buddha.png > > I used TweakPNG (Win32only) to learn about PNG and inset my REBOL script. > http://entropymine.com/jason/tweakpng/ > > By design I insert a special keyword "REBOLscript" after the "tEXt" chunk to > help parsing. Also, a special REBOL end of script marker ";EOF" at the end > of test script itself. The helps parsing the REBOL script end from other > data or padding in the PNG file. > > It takes about 6 seconds to store 29kb image file as a string on a 500Mhz > PIII Win98se Vaio laptop. > > Lots of features and funtions to implement. > But first I need some basic advice: > > Q1. How can I improve the time to load PNG into a rebol string? > Q2. What other approach do you suggest than the one I am following? > > thanks for any feedback > - Jason > > > REBOL [ File: %buddha.r] > > ;download or read from http://www.postcardscience/rebol/buddha.png > > buddha: read/binary %buddha.png > > b: "" for i 1 length? buddha 1 [append b to-char buddha/:i] > ; 7 seconds for 29Kb image on 500MhzPIII > > ; head b ; make sure we are at the beginning when debugging in REBOL shell > > search-key: "tEXtREBOLscript" ; better than just looking for "REBOL" > header-key: "REBOL " ; space after REBOL should mean it's the > header > tail-key: ";EOF" ; by design, this marks end of REBBOl > script > > ; later probably will want to include #!path-to-rebol and find those first > > b: find next b search-key ; start of our tEXt chunk containing REBOL > script > b: find next b header-key ; start of the script > start-mark: length? b ; how many bytes to end of PNG file > > bend: find next b tail-key ; end of script > end-mark: length? bend ; how many bytes to chop off > script-length: start-mark - end-mark ; how many bytes to use of 'script > > script: "" > for i 1 script-length 1 [append script b/:i] ; chop the end off so we have > pure script > write %buddha-script.r script ; save it to file > > do %buddha-script.r ; test it! > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 The contradiction so puzzling to the ordinary way of thinking comes from the fact that we have to use language to communicate our inner experience which in its very nature transcends lingistics. -D.T. Suzuki