1 /* vim:set sw=2 sts=2 et cin: */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef NSIMAGETOPIXBUF_H_ 7 #define NSIMAGETOPIXBUF_H_ 8 9 #include "mozilla/Attributes.h" 10 #include "mozilla/Maybe.h" 11 #include "nsSize.h" 12 13 class imgIContainer; 14 typedef struct _GdkPixbuf GdkPixbuf; 15 16 namespace mozilla::gfx { 17 class SourceSurface; 18 } // namespace mozilla::gfx 19 20 class nsImageToPixbuf final { 21 using SourceSurface = mozilla::gfx::SourceSurface; 22 23 public: 24 // Friendlier version of ConvertImageToPixbuf for callers inside of 25 // widget 26 /** 27 * The return value of all these, if not null, should be 28 * released as needed by the caller using g_object_unref. 29 */ 30 static GdkPixbuf* ImageToPixbuf( 31 imgIContainer* aImage, 32 const mozilla::Maybe<nsIntSize>& aOverrideSize = mozilla::Nothing()); 33 static GdkPixbuf* SourceSurfaceToPixbuf(SourceSurface* aSurface, 34 int32_t aWidth, int32_t aHeight); 35 36 private: 37 ~nsImageToPixbuf() = default; 38 }; 39 40 #endif 41