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 _ 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()
El manejo de imagenes
Re: El manejo de imagenes
He seguido trabajando en ello y tengo algo un poco mejor :
Re: El manejo de imagenes
Se tiene que enlazar con framework Quarz ...
el codigo del ejemplo anterior :
la clase :
y el archivo IKIMAGE.m :
el codigo del ejemplo anterior :
Code: Select all
// 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
Code: Select all
#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
//----------------------------------------------------------------------------//
Code: Select all
#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 ];
}
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: