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/>
29 #include <lqr/lqr_base.h>
30 #include <lqr/lqr_progress.h>
34 lqr_progress_new(void)
36 LqrProgress
*progress
;
37 LQR_TRY_N_N(progress
= g_try_new0(LqrProgress
, 1));
39 lqr_progress_set_init_width_message(progress
, "Resizing width...");
40 lqr_progress_set_init_height_message(progress
, "Resizing height...");
41 lqr_progress_set_end_width_message(progress
, "done");
42 lqr_progress_set_end_height_message(progress
, "done");
43 lqr_progress_set_update_step(progress
, (float) 0.02);
49 lqr_progress_init(LqrProgress
* p
, const gchar
*message
)
51 LQR_CATCH_F(p
!= NULL
);
53 return p
->init(message
);
60 lqr_progress_update(LqrProgress
* p
, gdouble percentage
)
62 LQR_CATCH_F(p
!= NULL
);
64 return p
->update(percentage
);
71 lqr_progress_end(LqrProgress
* p
, const gchar
*message
)
73 LQR_CATCH_F(p
!= NULL
);
75 return p
->end(message
);
83 lqr_progress_set_init(LqrProgress
* p
, LqrProgressFuncInit init_func
)
91 lqr_progress_set_update(LqrProgress
* p
, LqrProgressFuncUpdate update_func
)
93 p
->update
= update_func
;
99 lqr_progress_set_end(LqrProgress
* p
, LqrProgressFuncEnd end_func
)
107 lqr_progress_set_update_step(LqrProgress
* p
, gfloat update_step
)
109 p
->update_step
= update_step
;
115 lqr_progress_set_init_width_message(LqrProgress
* p
, const gchar
*message
)
118 g_strlcpy(p
->init_width_message
, message
, LQR_PROGRESS_MAX_MESSAGE_LENGTH
);
124 lqr_progress_set_init_height_message(LqrProgress
* p
, const gchar
*message
)
126 LQR_CATCH_F(p
!= NULL
);
127 g_strlcpy(p
->init_height_message
, message
, LQR_PROGRESS_MAX_MESSAGE_LENGTH
);
133 lqr_progress_set_end_width_message(LqrProgress
* p
, const gchar
*message
)
135 LQR_CATCH_F(p
!= NULL
);
136 g_strlcpy(p
->end_width_message
, message
, LQR_PROGRESS_MAX_MESSAGE_LENGTH
);
142 lqr_progress_set_end_height_message(LqrProgress
* p
, const gchar
*message
)
144 LQR_CATCH_F(p
!= NULL
);
145 g_strlcpy(p
->end_height_message
, message
, LQR_PROGRESS_MAX_MESSAGE_LENGTH
);