1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <Carbon/Carbon.h>
22 #include <QuickTime/QuickTime.h>
27 #include "PictToBmpFlt.hxx"
29 bool ImageToPNG( com::sun::star::uno::Sequence
<sal_Int8
>& rImgData
,
30 com::sun::star::uno::Sequence
<sal_Int8
>& rPngData
,
31 NSBitmapImageFileType eInFormat
)
33 (void) eInFormat
; // Really not needed? Weird.
35 NSData
* pData
= [NSData dataWithBytesNoCopy
: (void*)rImgData
.getConstArray() length
: rImgData
.getLength() freeWhenDone
: 0];
39 NSBitmapImageRep
* pRep
=[NSBitmapImageRep imageRepWithData
: pData
];
43 NSData
* pOut
= [pRep representationUsingType
: NSPNGFileType properties
: nil
];
47 const size_t nPngSize
= [pOut length
];
48 rPngData
.realloc( nPngSize
);
49 [pOut getBytes
: rPngData
.getArray() length
: nPngSize
];
50 return (nPngSize
> 0);
53 bool PNGToImage( com::sun::star::uno::Sequence
<sal_Int8
>& rPngData
,
54 com::sun::star::uno::Sequence
<sal_Int8
>& rImgData
,
55 NSBitmapImageFileType eOutFormat
58 NSData
* pData
= [NSData dataWithBytesNoCopy
: const_cast<sal_Int8
*>(rPngData
.getConstArray()) length
: rPngData
.getLength() freeWhenDone
: 0];
62 NSBitmapImageRep
* pRep
= [NSBitmapImageRep imageRepWithData
: pData
];
66 NSData
* pOut
= [pRep representationUsingType
: eOutFormat properties
: nil
];
70 const size_t nImgSize
= [pOut length
];
71 rImgData
.realloc( nImgSize
);
72 [pOut getBytes
: rImgData
.getArray() length
: nImgSize
];
73 return (nImgSize
> 0);
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */