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

[REBOL] Manipulating Images - Newbie question

From: kalefb::nortelnetworks::com at: 16-Aug-2001 13:31

I have been attempting to modify Carl's viewer.r script to allow me to create a button that will Rotate and then save the selected image in it's rotated state. My problem is that when I save the image, the rotation that is being displayed using /View doesn't actually save out to the file. I am not clear on how to modify the actual image as opposed to just the 'effect on the face. I hope this is clear. Below is Carl's code with my addition of the Rotate button. Thanks. Brock Kalef -- A wanna be Rebol'er -- ------------x snip x----------- REBOL [ Title: "Image Viewer" File: %viewer.r Date: 20-May-2000 Author: "Carl Sassenrath" Purpose: { A useful image viewer that shows all the jpeg, gif, bmp, png images found in the current directory. } Enhancements: { I would like to make this into a quick app to view, rotate, rename and save pictures from a digital camera. Also allow for random image playback. * button to rotate then auto-save * allow to change and auto-save name - if changed * Random button to allow for random image playback when only the 'next' button is pressed. Would require a memory of the images displayed. } Category: [view VID 3] ] page-size: 800x600 image-file?: func ["Returns true if file is an image" file] [ find [%.bmp %.jpg %.jpeg %.gif %.png] find/last file "." ] files: read %. ;-- Read local file list, but want just image files... while [not tail? files] [ either image-file? first files [files: next files][remove files] ] files: head files if empty? files [ inform layout [backdrop 140.0.0 text bold "No images found"] do-events quit ] view layout [ size page-size origin 10x10 img: image page-size - 20x50 first files effect none ; -- Face used to display image across at page-size * 0x1 + 10x-30 arrow left 24x24 keycode 'left [ files: back files name/text: first files show name img/image: load first files show img ;img/effect: [none] show img ] arrow right 24x24 keycode 'right [ if tail? files: next files [files: back files] name/text: first files show name img/image: load first files show img img_ref: load first files ;img/effect: [none] show img ] rt8: toggle "Rotate" keycode 'up [ ; img/image: img_ref effect rotate 90 show img img/effect: either rt8/state [[rotate 90]][none] show img save/png %atestimage.png to-image img ] tgl: toggle "Scale" [ img/effect: either tgl/state ['aspect][none] show img ] button "Quit" #"^(ESC)" [quit] name: field 300x24 form first files ]