2
2
// mgui/project/thumbnail.cpp
3
3
// This file is part of Bombono DVD project.
5
// Copyright (c) 2008-2009 Ilya Murav'jov
5
// Copyright (c) 2008-2010 Ilya Murav'jov
7
7
// This program is free software; you can redistribute it and/or modify
8
8
// it under the terms of the GNU General Public License as published by
52
52
ptr::weak_intrusive<VideoMD> curVI;
53
53
Mpeg::FwdPlayer player;
55
BrowserCache() { SetOutputFormat(player, fofRGB); }
55
BrowserCache() { RGBOpen(player); }
58
58
static Mpeg::FwdPlayer& OpenCachePlayer(VideoItem vmd)
61
61
if( (cache.curVI.lock() != vmd) || !cache.player.IsOpened() )
64
bool is_open = cache.player.Open(GetFilename(*vmd).c_str());
64
CheckOpen(cache.player, GetFilename(*vmd));
67
66
return cache.player;
70
RefPtr<Gdk::Pixbuf> GetVideoFrame(VideoItem vmd, double time, const Point& sz)
72
Mpeg::FwdPlayer& player = OpenCachePlayer(vmd);
73
RefPtr<Gdk::Pixbuf> pix = CreatePixbuf(sz);
74
return GetFrame(pix, time, player);
69
//RefPtr<Gdk::Pixbuf> GetVideoFrame(VideoItem vmd, double time, const Point& sz)
71
// Mpeg::FwdPlayer& player = OpenCachePlayer(vmd);
72
// RefPtr<Gdk::Pixbuf> pix = CreatePixbuf(sz);
73
// return GetFrame(pix, time, player);
76
const double VIDEO_THUMB_TIME = 0.;
78
VideoStart GetVideoStart(MediaItem mi)
82
if( VideoItem vi = IsVideo(mi) )
85
res.second = VIDEO_THUMB_TIME;
87
else if( ChapterItem ci = IsChapter(mi) )
89
res.first = ci->owner;
90
res.second = ci->chpTime;
97
VideoPE::VideoPE(VideoStart vs): plyr(OpenCachePlayer(vs.first)), time(vs.second) {}
99
static VideoPE* CreateVideoPE(Media& md)
101
return new VideoPE(GetVideoStart(&md));
77
104
void PrimaryShotGetter::Visit(VideoMD& obj)
79
const double VIDEO_THUMB_TIME = 0.;
80
pixExt = new VideoPE(OpenCachePlayer(&obj), VIDEO_THUMB_TIME);
106
pixExt = CreateVideoPE(obj);
83
109
void PrimaryShotGetter::Visit(VideoChapterMD& obj)
85
pixExt = new VideoPE(OpenCachePlayer(obj.owner), obj.chpTime);
111
pixExt = CreateVideoPE(obj);
88
114
void PrimaryShotGetter::Visit(ColorMD& obj)
132
158
void ThumbSizeCalcer::Visit(StillImageMD& obj)
134
160
bool true_ = gdk_pixbuf_get_file_info(GetFilename(obj).c_str(), &sz.x, &sz.y);
161
ASSERT_OR_UNUSED( true_ );
137
163
// вычисляем размеры кэша
138
164
sz = CalcProportionSize(sz, ORIG_ITEM_AREA);
252
278
RefPtr<Gdk::Pixbuf> GetCalcedShot(MediaItem mi)
254
using namespace boost;
255
return GetInteractiveLRS( lambda::bind(&GetCalcedShotImpl, mi) );
280
return GetInteractiveLRS( bb::bind(&GetCalcedShotImpl, mi) );
258
283
void SetDirtyCacheShot(MediaItem mi)
303
328
static void FillPixbuf(RefPtr<Gdk::Pixbuf>& pix, RefPtr<Gdk::Pixbuf> src, bool read_only)
307
Point sz = PixbufSize(src);
308
if( sz == PixbufSize(pix) )
309
src->copy_area(0, 0, sz.x, sz.y, pix, 0, 0);
311
RGBA::Scale(pix, src);
331
RGBA::CopyOrScale(pix, src);
314
333
pix = PixbufSource(src, read_only).RWPixbuf();
365
384
if( AData().FirstPlayItem() != mi )
367
386
bool is_menu = IsMenu(mi);
368
RefPtr<Gdk::Pixbuf> emblem = GetFactoryImage(is_menu ? "copy-n-paste/HelixPlayer_Activity-watch-listen/28.png"
369
: "copy-n-paste/HelixPlayer_Activity-watch-listen/16.png");
370
CheckEmblem(pix, emblem);
373
Point e_sz(PixbufSize(emblem));
374
Point p_sz(PixbufSize(pix));
375
Rect plc = RectASz(Point(2, is_menu ? (p_sz.y-e_sz.y)/2 : 2), e_sz);
376
RGBA::AlphaComposite(pix, emblem, plc);
387
RefPtr<Gdk::Pixbuf> emblem = GetCheckEmblem(pix, is_menu
388
? "copy-n-paste/HelixPlayer_Activity-watch-listen/28.png"
389
: "copy-n-paste/HelixPlayer_Activity-watch-listen/16.png");
390
RGBA::AlphaComposite(pix, emblem, Point(2, is_menu ? (pix->get_height() - emblem->get_height())/2 : 2));
379
393
} // namespace Project