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

Manipulating Images - Newbie question

 [1/4] 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 ]

 [2/4] from: arolls:bigpond:au at: 17-Aug-2001 4:41


view layout [ img: image %yourimage.png button "rotate 90" [ img/image: to-image layout [ origin 0 image img/image effect [rotate 90] ] show img ] button "save" [save/png %atestimage.png img/image] ] so the modified image is saved back onto itself, and pressing rotate several times continues to rotate the image. You will need recode it a bit for images where width <> height, otherwise some info gets chopped off.

 [3/4] from: bkalef:sympatico:ca at: 17-Aug-2001 14:30


Anton, Thanks very much for your prompt reply. Your code is definitely what I was right on the mark for what I was looking to do. I never thought to use another 'view. Cudos again to those on the list who 'know' providing those of us who don't a helping hand. It's greatly appreciated. Brock Kalef

 [4/4] from: arolls:bigpond:au at: 18-Aug-2001 15:01


> Anton, > Thanks very much for your prompt reply. Your code is definitely > what I was right on the mark for what I was looking to do. I > never thought to use another 'view.
Welcome. Just to be sure, it was using another layout, not another view. :) It's pretty cool how to-image can convert from a face. You can do multi-layered effects. I don't have time to explore all the possibilities, but I try. You have to help me find all the coolest stuff. :) Anton.