51
51
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
52
52
//C- +------------------------------------------------------------------
54
// $Id: DjVuImage.cpp,v 1.10 2005/04/27 16:34:13 leonb Exp $
55
// $Name: debian_version_3_5_16-1 $
54
// $Id: DjVuImage.cpp,v 1.13 2006/01/19 15:20:41 leonb Exp $
55
// $Name: debian_version_3_5_17-1 $
57
57
#ifdef HAVE_CONFIG_H
58
58
# include "config.h"
1075
1075
GRect rect=inrect;
1076
1076
GRect all=inall;
1078
if( dimg.get_rotate()%4 )
1077
if( dimg.get_rotate() )
1080
1079
GRectMapper mapper;
1081
mapper.rotate((4-dimg.get_rotate())%4);
1080
mapper.rotate(-dimg.get_rotate());
1082
1081
mapper.map(rect);
1083
1082
mapper.map(all);
1085
///* rotate code ends
1088
1086
if (! ( all.contains(rect.xmin, rect.ymin) &&
1089
1087
all.contains(rect.xmax-1, rect.ymax-1) ))
1112
1110
(rw*red*3 < w || rh*red*3 < h) )
1114
1112
// Setup bitmap scaler
1115
if (! (w && h)) return 0;
1113
if (w<=0 || h<=0) return 0;
1116
1114
GP<GBitmapScaler> gbs=GBitmapScaler::create();
1117
1115
GBitmapScaler &bs=*gbs;
1118
1116
bs.set_input_size( (w+red-1)/red, (h+red-1)/red );
1128
1126
GP<GBitmap> bm = GBitmap::create(zrect.height(), zrect.width(), border);
1129
1127
bs.scale(srect, *sbm, zrect, *bm);
1131
return bm->rotate((4-dimg.get_rotate())%4);
1129
return bm->rotate(dimg.get_rotate());
1137
1135
do_pixmap(const DjVuImage &dimg, PImager get,
1138
1136
const GRect &inrect, const GRect &inall, double gamma )
1144
if( dimg.get_rotate()%4 )
1140
if( dimg.get_rotate()%4 )
1147
mapper.rotate((4-dimg.get_rotate())%4);
1143
mapper.rotate(-dimg.get_rotate());
1151
///* rotate code ends
1154
1149
if (! ( all.contains(rect.xmin, rect.ymin) &&
1155
1150
all.contains(rect.xmax-1, rect.ymax-1) ))
1181
1175
(rw*red*3 < w || rh*red*3 < h) )
1183
1177
// Setup pixmap scaler
1184
if (w<0 || h<0) return 0;
1178
if (w<=0 || h<=0) return 0;
1185
1179
GP<GPixmapScaler> gps=GPixmapScaler::create();
1186
1180
GPixmapScaler &ps=*gps;
1187
1181
ps.set_input_size( (w+red-1)/red, (h+red-1)/red );
1196
1190
GP<GPixmap> pm = GPixmap::create();
1197
1191
ps.scale(srect, *spm, zrect, *pm);
1199
return pm->rotate((4-dimg.get_rotate())%4);
1193
return pm->rotate(dimg.get_rotate());
1229
1223
DjVuImage::get_rotate() const
1231
return (rotate_count<0)?0:rotate_count;
1225
return (rotate_count<0) ? 0 : rotate_count;
1235
1229
DjVuImage::init_rotate(const DjVuInfo &info)
1237
rotate_count=((360-GRect::findangle(info.orientation))/90)%4;
1231
rotate_count = info.orientation;
1240
1234
void DjVuImage::set_rotate(int count)
1242
rotate_count=((count%4)+4)%4;
1236
rotate_count = count % 4;
1246
1240
DjVuImage::get_decoded_anno()
1242
GP<DjVuInfo> djvuinfo = get_info();
1248
1243
GP<DjVuAnno> djvuanno = DjVuAnno::create();
1249
1244
GP<ByteStream> bs=get_anno();
1252
djvuanno->decode(bs);
1254
const int rotate_count=get_rotate();
1255
if( rotate_count % 4 )
1247
int rotate_count=get_rotate();
1248
/// Brain damaged adjustment of annotation
1249
/// coordinates that reflect the orientation
1250
/// flag in the info chunk....
1252
rotate_count = rotate_count - djvuinfo->orientation;
1254
djvuanno->decode(bs);
1255
///map hyperlinks correctly for rotation
1256
if( rotate_count & 3 )
1257
///map hyperlinks correctly for rotation
1258
GRect input, output;
1259
input = GRect(0,0,get_width(), get_height());
1260
output = GRect(0,0, get_real_width(), get_real_height());
1264
mapper.set_input(input);
1265
mapper.set_output(output);
1266
mapper.rotate((4-rotate_count)%4);
1268
GPList<GMapArea> &list=djvuanno->ant->map_areas;
1269
for(GPosition pos=list;pos;++pos)
1271
list[pos]->unmap(mapper);
1258
GRect input, output;
1259
input = GRect(0,0,get_width(),get_height());
1260
if (rotate_count & 1)
1261
output = GRect(0,0,get_height(),get_width());
1263
output = GRect(0,0,get_width(),get_height());
1266
mapper.set_input(input);
1267
mapper.set_output(output);
1268
mapper.rotate(-rotate_count);
1269
GPList<GMapArea> &list=djvuanno->ant->map_areas;
1270
for(GPosition pos=list;pos;++pos)
1271
list[pos]->unmap(mapper);
1284
1283
GRect input, output;
1285
1284
const int rotate_count=get_rotate();
1288
1287
input = GRect(0,0,get_width(), get_height());
1289
1288
output = GRect(0,0, get_real_width(), get_real_height());
1303
1302
GRect input, output;
1304
1303
const int rotate_count=get_rotate();
1307
1306
input = GRect(0,0,get_width(), get_height());
1308
1307
output = GRect(0,0, get_real_width(), get_real_height());
1322
1321
GRect input, output;
1323
1322
const int rotate_count=get_rotate();
1326
1325
input = GRect(0,0,get_width(), get_height());
1327
1326
output = GRect(0,0, get_real_width(), get_real_height());
1341
1340
GRect input, output;
1342
1341
const int rotate_count=get_rotate();
1345
1344
input = GRect(0,0,get_width(), get_height());
1346
1345
output = GRect(0,0, get_real_width(), get_real_height());