LibreOffice Module vcl (master) 1
GraphicNativeMetadata.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <vcl/gfxlink.hxx>
22#include "jpeg/Exif.hxx"
23#include <memory>
24
26 : mRotation(0)
27{
28}
29
31{
32 GfxLink aLink = rGraphic.GetGfxLink();
33 if (aLink.GetType() != GfxLinkType::NativeJpg)
34 return false;
35
36 sal_uInt32 aDataSize = aLink.GetDataSize();
37 if (!aDataSize)
38 return false;
39
40 std::unique_ptr<sal_uInt8[]> aBuffer(new sal_uInt8[aDataSize]);
41
42 memcpy(aBuffer.get(), aLink.GetData(), aDataSize);
43 SvMemoryStream aMemoryStream(aBuffer.get(), aDataSize, StreamMode::READ);
44
45 read(aMemoryStream);
46
47 return true;
48}
49
51{
52 Exif aExif;
53 aExif.read(rStream);
54 mRotation = aExif.getRotation();
55
56 return true;
57}
58
59/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: Exif.hxx:44
bool read(SvStream &rStream)
Definition: Exif.cxx:66
Degree10 getRotation() const
Definition: Exif.cxx:49
bool read(Graphic const &rGraphic)
GfxLink GetGfxLink() const
Definition: graph.cxx:510
unsigned char sal_uInt8
std::unique_ptr< char[]> aBuffer