mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 19:01:15 +00:00
Add image rep for svg
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/svgimagerep@40267 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3fec9906a5
commit
9ce45060d3
3 changed files with 125 additions and 0 deletions
|
@ -59,6 +59,7 @@ NSBitmapImageRep+ICNS.m \
|
|||
NSBitmapImageRep+JPEG.m \
|
||||
NSBitmapImageRep+PNG.m \
|
||||
NSBitmapImageRep+PNM.m \
|
||||
NSBitmapImageRep+SVG.m \
|
||||
NSBox.m \
|
||||
NSBrowser.m \
|
||||
NSBrowserCell.m \
|
||||
|
|
42
Source/NSBitmapImageRep+SVG.h
Normal file
42
Source/NSBitmapImageRep+SVG.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
NSBitmapImageRep+SVG.m
|
||||
|
||||
Methods for loading .icns images.
|
||||
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Gregory Casamento
|
||||
Date: 2008-08-12
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSBitmapImageRep_SVG_H_include
|
||||
#define _NSBitmapImageRep_SVG_H_include
|
||||
|
||||
#import "AppKit/NSBitmapImageRep.h"
|
||||
|
||||
@interface NSBitmapImageRep (SVG)
|
||||
+ (BOOL) _bitmapIsSVG: (NSData *)imageData;
|
||||
+ (NSArray*) _imageRepsWithSVGData: (NSData *)imageData;
|
||||
- (id) _initBitmapFromSVG: (NSData *)imageData;
|
||||
// - (NSData *) _SVGRepresentationWithProperties: (NSDictionary *) properties;
|
||||
@end
|
||||
|
||||
#endif
|
82
Source/NSBitmapImageRep+SVG.m
Normal file
82
Source/NSBitmapImageRep+SVG.m
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
NSBitmapImageRep+SVG.m
|
||||
|
||||
Methods for loading .svg images.
|
||||
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Gregory Casamento
|
||||
Date: 2016-11-26
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "config.h"
|
||||
#import "NSBitmapImageRep+SVG.h"
|
||||
#import <Foundation/NSByteOrder.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import "AppKit/NSGraphics.h"
|
||||
#import "GSGuiPrivate.h"
|
||||
#include <librsvg-2.0/librsvg/rsvg.h>
|
||||
|
||||
#define SVG_HEADER @"SVG"
|
||||
#define XML_HEADER @"DOCTYPE"
|
||||
|
||||
@implementation NSBitmapImageRep (SVG)
|
||||
|
||||
+ (BOOL) _bitmapIsSVG: (NSData *)imageData
|
||||
{
|
||||
NSString *string = nil;
|
||||
|
||||
/*
|
||||
* If the data is 0, return immediately.
|
||||
*/
|
||||
if ([imageData length] < 8)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the beginning of the data for
|
||||
* the string "svg" or "doctype".
|
||||
*/
|
||||
string = [NSString stringWithUTF8String:[imageData bytes]];
|
||||
if([string containsString: SVG_HEADER] &&
|
||||
[string containsString: XML_HEADER])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (NSArray*) _imageRepsWithSVGData: (NSData *)imageData
|
||||
{
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
return array;
|
||||
}
|
||||
|
||||
- (id) _initBitmapFromSVG: (NSData *)imageData
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue