El manejo de imagenes

Post Reply
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

El manejo de imagenes

Post by mastintin »

Me he puesto a investigar la parte de gestion de imagenes en mac , todo un mundo lo que tenemos .De momento he conseguido presentar una imagen , voltearla ,fijarla al marco , y editarla ( no he realizado la gestion de grabar los cambios pero pienso que no será dificil ) .
Cunado tenga implementadfa la clase y los comandos lo que veis se podra resumir en dos lineas :

@30,20 SIMAGE oImage FILENAME "mi archivo" SIZE 800, 450 FIT
oImage:edit()


Image
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: El manejo de imagenes

Post by mastintin »

He seguido trabajando en ello y tengo algo un poco mejor :


Image
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: El manejo de imagenes

Post by mastintin »

Se tiene que enlazar con framework Quarz ...

el codigo del ejemplo anterior :

Code: Select all | Expand

// Building our first window#include "FiveMac.ch"#xcommand @ <nRow>, <nCol> SIMAGE [ <oImage> ] ;             [ FILENAME <cFileName> ] ;              [ OF <oWnd> ] ;                [ SIZE <nWidth>, <nHeight> ] ;              => ;                 [ <oImage> := ] TSimage():New( <nRow>, <nCol>, <nWidth>, <nHeight>, <oWnd>,[<(cFileName)>] )//----------------------------------------------------------------------------//function Main()   local oWnd, oSay   local oImage   local path := path()      DEFINE WINDOW oWnd TITLE "Tutor02" ;       FROM 200, 250 TO 750, 1100   DEFINE TOOLBAR oBar OF oWnd     DEFINE BUTTON OF oBar PROMPT "Rotate left" ;      TOOLTIP "Creates a new file" ;       IMAGE path+"/RotateLeft.tif" ;      ACTION oImage:rotateleft()DEFINE BUTTON OF oBar PROMPT "Rotate Right" ;      TOOLTIP "Creates a new file" ;       IMAGE path+"/RotateRight.tif" ;      ACTION oImage:rotateRight()         DEFINE BUTTON OF oBar PROMPT "Zoom In" ;      TOOLTIP "Creates a new file" ;       IMAGE path+"/ZoomIn.tif" ;            ACTION oImage:zoomin()      DEFINE BUTTON OF oBar PROMPT "Zoom Out" ;      TOOLTIP "Creates a new file" ;       IMAGE path+"/ZoomOut.tif" ;      ACTION oImage:zoomOut()         DEFINE BUTTON OF oBar PROMPT "Zoom Fit" ;        IMAGE path+"/SizeToFit.tif" ;      ACTION oImage:fit()       DEFINE BUTTON OF oBar PROMPT "Tools edit" ;        IMAGE path+"/tools_adjust.tiff" ;      ACTION oImage:edit()      DEFINE BUTTON OF oBar PROMPT "Cortar" ;        IMAGE path+"/crop.tiff" ;      ACTION oImage:crop()  DEFINE BUTTON OF oBar PROMPT "Rotar" ;        IMAGE path+"/rotate.tiff" ;      ACTION oImage:rotate()    DEFINE BUTTON OF oBar PROMPT "Cursor Normal" ;        IMAGE path+"/cursor.tiff" ;      ACTION oImage:normal()          DEFINE MSGBAR OF oWnd          @ 24,0 SIMAGE oImage FILENAME "/Users/manuel/Pictures/mg7656webtu6.jpg" OF oWnd SIZE 850,525          @ 0, 10 SAY "Para editar DLBclick en la imagen" OF oWnd SIZE 350, 20 RAISED   ACTIVATE WINDOW oWnd ;           VALID MsgYesNo( "Want to end ?" )return nil 


la clase :

Code: Select all | Expand

#include "FiveMac.ch"//----------------------------------------------------------------------------//CLASS TSimage FROM TControl   METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, cPrompt, nStyle )   METHOD Open(cImage) INLINE IKImageOpen(::hWnd,cImage)     METHOD Fit() INLINE IKImageFit(::hWnd )      METHOD VerticalFlip() INLINE IKImageVFLIP(::hWnd )      METHOD edit() INLINE IKImageedit(::hWnd )      METHOD setautoresize(lauto) INLINE  IKIMAGESETAUTORESIZE(::hWnd,lauto)      METHOD Getautoresize() INLINE IKImagegetautoresize(::hWnd)      METHOD zoomin() INLINE IKImagezoomIn(::hWnd)      METHOD zoomOut() INLINE IKImagezoomOut(::hWnd)      METHOD Rotateleft() INLINE IKImageRotaLeft(::hWnd)       METHOD RotateRight() INLINE IKImageRotaRight(::hWnd)            METHOD crop() INLINE  IKIMAGESETCROP(::hWnd)        METHOD rotate() INLINE IKIMAGESETROTATE(::hwnd)        MEthod Normal() INLINE IKIMAGESETNORMAL(::hwnd)                                                ENDCLASS   //----------------------------------------------------------------------------//METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, cImage ) CLASS TSimage   DEFAULT nWidth := 100, nHeight := 200, oWnd := GetWndDefault()      ::hWnd = IKImageCreate( nTop, nLeft, nWidth, nHeight, oWnd:hWnd )      if !Empty(cImage)      IKImageOpen(::hWnd,cImage)      endif      ::oWnd = oWnd      oWnd:AddControl( Self )   return Self//----------------------------------------------------------------------------// 


y el archivo IKIMAGE.m :

Code: Select all | Expand

#import <Cocoa/Cocoa.h>#import "Quartz/Quartz.h"#define HB_DONT_DEFINE_BOOL#include <hbapi.h>NSView * GetView( NSWindow * window );HB_FUNC( IKIMAGECREATE ){        NSScrollView * sv = [ [ NSScrollView alloc ]                          initWithFrame : NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];            [ sv setAutoresizingMask : NSViewWidthSizable | NSViewHeightSizable ];    [ sv setHasVerticalScroller : YES ];    [ sv setHasHorizontalScroller : YES ];    [ sv setBorderType : NSBezelBorder ];        IKImageView * vista = [ [ IKImageView alloc ] initWithFrame : [ [ sv contentView ] frame ] ];           NSWindow * window = ( NSWindow * ) hb_parnl( 5 );        [ sv setDocumentView : vista ];         [ GetView( window ) addSubview : sv ];      // [ GetView( window ) addSubview : vista ];               hb_retnl( ( LONG ) vista );}HB_FUNC( IKIMAGEOPEN ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        NSString * path = [ [ [ NSString alloc ] initWithCString: ISCHAR( 2 ) ? hb_parc( 2 ) : "" ] autorelease ];        NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:path];            [vista  setImageWithURL:fileURL ];          }HB_FUNC( IKIMAGEFIT ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista zoomImageToFit:vista ];          }HB_FUNC( IKIMAGEZOOMIN ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista zoomIn:vista ];    }HB_FUNC( IKIMAGEROTALEFT ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista rotateImageLeft:vista ];    }HB_FUNC( IKIMAGEROTARIGHT ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista rotateImageRight:vista ];    }HB_FUNC( IKIMAGEZOOMOUT ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista zoomOut:vista ];    }HB_FUNC( IKIMAGEVFLIP ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista flipImageVertical:vista ];    }HB_FUNC( IKIMAGEEDIT ){    IKImageView * vista = ( IKImageView *) hb_parnl( 1 );        [vista setCurrentToolMode: IKToolModeMove];    [vista setDoubleClickOpensImageEditPanel: YES];}HB_FUNC( IKIMAGESETAUTORESIZE ){        IKImageView * vista = ( IKImageView  *) hb_parnl( 1 );    [ vista setAutoresizes: hb_parl( 2 ) ];}HB_FUNC( IKIMAGEGETAUTORESIZE ){        IKImageView  * vista = ( IKImageView  *) hb_parnl( 1 );    hb_retl( ( BOOL ) [vista autoresizes ]);}HB_FUNC( IKIMAGESETCROP ){        IKImageView * vista = ( IKImageView  *) hb_parnl( 1 );    [ vista setCurrentToolMode: IKToolModeCrop ];}HB_FUNC( IKIMAGESETROTATE ){    IKImageView * vista = ( IKImageView  *) hb_parnl( 1 );    [ vista setCurrentToolMode: IKToolModeRotate ];}HB_FUNC( IKIMAGESETNORMAL ){    IKImageView * vista = ( IKImageView  *) hb_parnl( 1 );    [ vista setCurrentToolMode: IKToolModeNone ];} 
User avatar
Antonio Linares
Site Admin
Posts: 42514
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: El manejo de imagenes

Post by Antonio Linares »

Realmente bueno :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply