1 /* LiquidRescaling Library
2 * Copyright (C) 2007-2009 Carlo Baldassi (the "Author") <carlobaldassi@gmail.com>.
5 * This library implements the algorithm described in the paper
6 * "Seam Carving for Content-Aware Image Resizing"
7 * by Shai Avidan and Ariel Shamir
8 * which can be found at http://www.faculty.idc.ac.il/arik/imret.pdf
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; version 3 dated June, 2007.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>
25 #include <lqr/lqr_all.h>
29 #endif /* __LQR_DEBUG__ */
32 /**** CARVER LIST FUNCTIONS ****/
35 lqr_carver_list_append (LqrCarverList
* list
, LqrCarver
* r
)
37 LqrCarverList
* prev
= NULL
;
38 LqrCarverList
* now
= list
;
44 TRY_N_N (now
= g_try_new(LqrCarverList
, 1));
62 lqr_carver_list_destroy(LqrCarverList
* list
)
64 LqrCarverList
* now
= list
;
67 lqr_carver_list_destroy(now
->next
);
68 lqr_carver_list_destroy(now
->current
->attached_list
);
69 lqr_carver_destroy(now
->current
);
75 lqr_carver_list_start (LqrCarver
*r
)
77 return r
->attached_list
;
82 lqr_carver_list_next (LqrCarverList
* list
)
90 lqr_carver_list_current (LqrCarverList
* list
)
98 lqr_carver_list_foreach (LqrCarverList
* list
, LqrCarverFunc func
, LqrDataTok data
)
100 LqrCarverList
* now
= list
;
103 CATCH (func(now
->current
, data
));
104 return lqr_carver_list_foreach (now
->next
, func
, data
);
111 lqr_carver_list_foreach_recursive (LqrCarverList
* list
, LqrCarverFunc func
, LqrDataTok data
)
113 LqrCarverList
* now
= list
;
116 CATCH (func(now
->current
, data
));
117 CATCH (lqr_carver_list_foreach (now
->current
->attached_list
, func
, data
));
118 return lqr_carver_list_foreach (now
->next
, func
, data
);