|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "ImageMetadata.h" |
|
8 |
|
9 #include "RasterImage.h" |
|
10 #include "nsComponentManagerUtils.h" |
|
11 #include "nsISupportsPrimitives.h" |
|
12 #include "nsXPCOMCID.h" |
|
13 |
|
14 using namespace mozilla::image; |
|
15 |
|
16 void |
|
17 ImageMetadata::SetOnImage(RasterImage* image) |
|
18 { |
|
19 if (mHotspotX != -1 && mHotspotY != -1) { |
|
20 nsCOMPtr<nsISupportsPRUint32> intwrapx = do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID); |
|
21 nsCOMPtr<nsISupportsPRUint32> intwrapy = do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID); |
|
22 intwrapx->SetData(mHotspotX); |
|
23 intwrapy->SetData(mHotspotY); |
|
24 image->Set("hotspotX", intwrapx); |
|
25 image->Set("hotspotY", intwrapy); |
|
26 } |
|
27 |
|
28 image->SetLoopCount(mLoopCount); |
|
29 |
|
30 for (uint32_t i = 0; i < image->GetNumFrames(); i++) { |
|
31 image->SetFrameAsNonPremult(i, mIsNonPremultiplied); |
|
32 } |
|
33 } |