Skip to content

Commit 1857b98

Browse files
U-admin-PC\adminU-admin-PC\admin
U-admin-PC\admin
authored and
U-admin-PC\admin
committed
added: invalid image format exception, rotate the object
1 parent 704e899 commit 1857b98

File tree

2 files changed

+70
-5
lines changed

2 files changed

+70
-5
lines changed

atp3/CViewMain.cpp

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Author: Ho-Jung Kim (godmode2k@hotmail.com)
55
Date: Since Dec 2, 2014
66
Filename: CViewMain.cpp
77
8-
Last modified: Feb 3, 2015
8+
Last modified: Feb 8, 2015
99
License:
1010
1111
*
@@ -1499,6 +1499,11 @@ bool CViewMain::attach_add_text(const char* text, const char* bg_img_filename,
14991499
if ( !text )
15001500
__LOGT__( TAG, "attach_add_text(): Text == NULL" );
15011501

1502+
if ( attach ) {
1503+
delete attach;
1504+
attach = NULL;
1505+
}
1506+
15021507
return false;
15031508
}
15041509

@@ -1565,12 +1570,26 @@ bool CViewMain::attach_add_text(const char* text, const char* bg_img_filename,
15651570
// Background Image
15661571
if ( !m_tmp_obj_bg_img_info.selected_bg_img ) {
15671572
if ( bg_img_filename ) {
1568-
attach->load_image( bg_img_filename );
1573+
if ( !attach->load_image(bg_img_filename) ) {
1574+
if ( attach ) {
1575+
delete attach;
1576+
attach = NULL;
1577+
}
1578+
1579+
return false;
1580+
}
15691581
}
15701582
}
15711583
else {
15721584
if ( m_tmp_obj_bg_img_info.bg_img_filename ) {
1573-
attach->load_image( m_tmp_obj_bg_img_info.bg_img_filename );
1585+
if ( !attach->load_image(m_tmp_obj_bg_img_info.bg_img_filename) ) {
1586+
if ( attach ) {
1587+
delete attach;
1588+
attach = NULL;
1589+
}
1590+
1591+
return false;
1592+
}
15741593
}
15751594
}
15761595

@@ -1698,6 +1717,11 @@ bool CViewMain::attach_add_image(const char* img_filename, const char* tag) {
16981717
if ( !img_filename )
16991718
__LOGT__( TAG, "attach_add_image(): Image filename == NULL" );
17001719

1720+
if ( attach ) {
1721+
delete attach;
1722+
attach = NULL;
1723+
}
1724+
17011725
return false;
17021726
}
17031727

@@ -1707,7 +1731,14 @@ bool CViewMain::attach_add_image(const char* img_filename, const char* tag) {
17071731
attach->set_obj_type( type );
17081732
attach->set_tag2( tag );
17091733
attach->set_obj_rect( 50.f, 50.f, 100.f, 100.f );
1710-
attach->load_image( img_filename );
1734+
if ( !attach->load_image(img_filename) ) {
1735+
if ( attach ) {
1736+
delete attach;
1737+
attach = NULL;
1738+
}
1739+
1740+
return false;
1741+
}
17111742

17121743
m_pvec_attach->push_back( attach );
17131744
}
@@ -1716,6 +1747,37 @@ bool CViewMain::attach_add_image(const char* img_filename, const char* tag) {
17161747
return true;
17171748
}
17181749

1750+
bool CViewMain::attach_rotate(void) {
1751+
//__LOGT__( TAG, "attach_rotate()" );
1752+
1753+
bool ret = false;
1754+
1755+
if ( !m_pvec_attach ) {
1756+
__LOGT__( TAG, "attach_rotate(): Attachment Container == NULL" );
1757+
return false;
1758+
}
1759+
1760+
if ( m_pvec_attach->size() > 0 ) {
1761+
std::vector<CViewAttach*>::iterator iter;
1762+
1763+
for ( iter = m_pvec_attach->begin(); iter != m_pvec_attach->end(); ++iter ) {
1764+
CViewAttach* attach = (*iter);
1765+
1766+
if ( attach ) {
1767+
if ( attach->get_selected() ) {
1768+
attach->set_obj_rotate( true );
1769+
ret = true;
1770+
1771+
break;
1772+
}
1773+
}
1774+
} // for()
1775+
}
1776+
1777+
1778+
return ret;
1779+
}
1780+
17191781
bool CViewMain::attach_delete(void) {
17201782
//__LOGT__( TAG, "attach_delete()" );
17211783

@@ -1845,6 +1907,7 @@ bool CViewMain::attach_invalidate(CBaseView* view) {
18451907
if ( attach ) {
18461908
if ( take_screenshot_get_region() ) {
18471909
attach->set_select( false );
1910+
attach->set_obj_rotate( false );
18481911
}
18491912

18501913
attach->invalidate( view );
@@ -1880,6 +1943,7 @@ bool CViewMain::attach_touch_event(CKeyEvent* event) {
18801943
if ( attach ) {
18811944
if ( found ) {
18821945
attach->set_select( false );
1946+
attach->set_obj_rotate( false );
18831947
continue;
18841948
}
18851949

atp3/CViewMain.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Author: Ho-Jung Kim (godmode2k@hotmail.com)
88
Date: Since Dec 2, 2014
99
Filename: CViewMain.h
1010
11-
Last modified: Feb 3, 2015
11+
Last modified: Feb 7, 2015
1212
License:
1313
1414
*
@@ -305,6 +305,7 @@ class CViewMain : virtual public CBaseView {
305305
bool attach_edit_text(const char* text, const char* bg_img_filename = NULL,
306306
const char* tag = NULL);
307307
bool attach_add_image(const char* img_filename, const char* tag = NULL);
308+
bool attach_rotate(void);
308309
bool attach_delete(void);
309310
bool attach_delete_all(void);
310311
CViewAttach* attach_selected(void);

0 commit comments

Comments
 (0)