How to extract an area in current image

Hello i have a question for my new game
I need extract a part of current image and save in new image
For exemple : imgnew = extract.image(x1,y1,x2,y2)
Do you have an idea ?
Thanks

imgnew = image:copy(x1,y1,x2,y2) where x1,y1 is bottom left and x2,y2 is top right.

yes but i have the error : attempt to index global image ( a function value )
i must define image before. i would like access direct to the screen

Only way to do this is to create an image and use setContext, drops fps by about 10 depends how many time you call setContext. The image should be the size of the screen and you can just sprite the image in the centre of the screen.

i can’t use image.get(x,y) to read in current picture then write in new picture with setcontext

Ofcourse you can, I have a 2d physics engine using a grid of 40 points that use img:get(x,y) to detect for ground or objects (anything not coloured 0,0,0,0). If you need an example I can write it for you.

sorry when i say current picture i will say the screen picture

i think i will be able to create the sprite in the pc computer and then move it in the ipad
because the sprite is an part of screen picture

You can create an image using image(WIDTH,HEIGHT) to set it to the size of the screen then use setContext(image) or image:set(x,y) for individual pixels. What sprite are you trying to make?

thanks luatee at the beginning i draw nothing in the screen
i draw always with setcontext

Hope it helped!

luatee : i bought your application today paint it pro. it s excellent and very complete.
i like the grid and pintch zoom. and all with codea !!! i like too the animation in menu i suppose with tween tools. i thinks it lacks arrows for flowchart for exemple and perhaps bigger area for drawing. perhaps replace menu with words by icon for save space. i suppose it s impossible to insert camera in picture and save picture in photo roll. very very good work.

@hpsoft thank you, I am currently waiting for a possible memory problem to be fixed with setContext() before I can update the app, I have a list of everything to do with icons for tools and a dynamic colour picker from each tool etc. I had a mess around with canvas sizes before but it’s quite hard to find every single dimension relating to the screen size and change it accurately, but it will be done along with save to camera roll and copy image to pasteboard (I prefer the latter as you don’t get white pixels in place of alpha pixels.