@@ -287,63 +287,6 @@ extension Image where Pixel == RGBA<Double> {
287287 }
288288}
289289
290- extension Image where Pixel == RGBA < Float80 > {
291- public init ( nsImage: NSImage ) {
292- if let cgImage: CGImage = nsImage. cgImage ( forProposedRect: nil , context: nil , hints: nil ) {
293- self . init ( cgImage: cgImage)
294- } else {
295- precondition ( nsImage. size == . zero, " The `size` of the given `NSImage` instance ( \( nsImage) ) must be equal to `.zero` when the `cgImage` of the instance is `nil`. " )
296- self . init ( width: 0 , height: 0 , pixels: [ ] )
297- }
298- }
299-
300- private init ? ( nsImageOrNil: NSImage ? ) {
301- guard let nsImage: NSImage = nsImageOrNil else { return nil }
302- self . init ( nsImage: nsImage)
303- }
304-
305- public init ? ( named name: NSImage . Name ) {
306- self . init ( nsImageOrNil: NSImage ( named: name) )
307- }
308-
309- public init ? ( contentsOfFile path: String ) {
310- self . init ( nsImageOrNil: NSImage ( contentsOfFile: path) )
311- }
312-
313- public init ? ( data: Data ) {
314- self . init ( nsImageOrNil: NSImage ( data: data) )
315- }
316-
317- public var nsImage : NSImage {
318- return NSImage ( cgImage: cgImage, size: . zero)
319- }
320-
321- public func data( using format: Image . Format ) -> Data ? {
322- guard width > 0 && height > 0 else { return nil }
323-
324- let imageRep = NSBitmapImageRep ( cgImage: cgImage)
325- imageRep. size = CGSize ( width: CGFloat ( width) , height: CGFloat ( height) )
326-
327- switch format {
328- case . png:
329- return imageRep. representation ( using: . png, properties: [ : ] )
330- case . jpeg( let complessionQuality) :
331- return imageRep. representation ( using: . jpeg, properties: [ . compressionFactor: NSNumber ( value: complessionQuality) ] )
332- }
333- }
334-
335- public func write( to url: URL , atomically: Bool , format: Image . Format ) throws {
336- guard let data = data ( using: format) else {
337- throw Image . Format. FormattingError< Image< RGBA< Float80>>> ( image: self , format: format)
338- }
339- try data. write ( to: url, options: atomically ? . atomic : . init( rawValue: 0 ) )
340- }
341-
342- public func write< S : StringProtocol > ( toFile path: S , atomically: Bool , format: Image . Format ) throws {
343- try write ( to: URL ( fileURLWithPath: String ( path) ) , atomically: atomically, format: format)
344- }
345- }
346-
347290extension Image where Pixel == RGBA < Bool > {
348291 public init ( nsImage: NSImage ) {
349292 if let cgImage: CGImage = nsImage. cgImage ( forProposedRect: nil , context: nil , hints: nil ) {
@@ -686,63 +629,6 @@ extension Image where Pixel == Double {
686629 }
687630}
688631
689- extension Image where Pixel == Float80 {
690- public init ( nsImage: NSImage ) {
691- if let cgImage: CGImage = nsImage. cgImage ( forProposedRect: nil , context: nil , hints: nil ) {
692- self . init ( cgImage: cgImage)
693- } else {
694- precondition ( nsImage. size == . zero, " The `size` of the given `NSImage` instance ( \( nsImage) ) must be equal to `.zero` when the `cgImage` of the instance is `nil`. " )
695- self . init ( width: 0 , height: 0 , pixels: [ ] )
696- }
697- }
698-
699- private init ? ( nsImageOrNil: NSImage ? ) {
700- guard let nsImage: NSImage = nsImageOrNil else { return nil }
701- self . init ( nsImage: nsImage)
702- }
703-
704- public init ? ( named name: NSImage . Name ) {
705- self . init ( nsImageOrNil: NSImage ( named: name) )
706- }
707-
708- public init ? ( contentsOfFile path: String ) {
709- self . init ( nsImageOrNil: NSImage ( contentsOfFile: path) )
710- }
711-
712- public init ? ( data: Data ) {
713- self . init ( nsImageOrNil: NSImage ( data: data) )
714- }
715-
716- public var nsImage : NSImage {
717- return NSImage ( cgImage: cgImage, size: . zero)
718- }
719-
720- public func data( using format: Image . Format ) -> Data ? {
721- guard width > 0 && height > 0 else { return nil }
722-
723- let imageRep = NSBitmapImageRep ( cgImage: cgImage)
724- imageRep. size = CGSize ( width: CGFloat ( width) , height: CGFloat ( height) )
725-
726- switch format {
727- case . png:
728- return imageRep. representation ( using: . png, properties: [ : ] )
729- case . jpeg( let complessionQuality) :
730- return imageRep. representation ( using: . jpeg, properties: [ . compressionFactor: NSNumber ( value: complessionQuality) ] )
731- }
732- }
733-
734- public func write( to url: URL , atomically: Bool , format: Image . Format ) throws {
735- guard let data = data ( using: format) else {
736- throw Image . Format. FormattingError< Image< Float80>>( image: self , format: format)
737- }
738- try data. write ( to: url, options: atomically ? . atomic : . init( rawValue: 0 ) )
739- }
740-
741- public func write< S : StringProtocol > ( toFile path: S , atomically: Bool , format: Image . Format ) throws {
742- try write ( to: URL ( fileURLWithPath: String ( path) ) , atomically: atomically, format: format)
743- }
744- }
745-
746632extension Image where Pixel == Bool {
747633 public init ( nsImage: NSImage ) {
748634 if let cgImage: CGImage = nsImage. cgImage ( forProposedRect: nil , context: nil , hints: nil ) {
0 commit comments