1014 | | pixmap_y = drawVideoBounds.y(); |
| 1017 | { |
| 1018 | QSize size = drawVideoBounds.size(); |
| 1019 | int voffset = 0, hoffset = 0; |
| 1020 | float vaspect = ((float) temp.width()) / ((float) temp.height()); |
| 1021 | |
| 1022 | if ( drawVideoBoundsAspect > vaspect) |
| 1023 | { |
| 1024 | // The aspect ratio of the preview window is greater than that of the image |
| 1025 | // being displayed. This can happen when trying to display a 4:3 image |
| 1026 | // in a 16:9 window. We need to calculate the width of the image. |
| 1027 | size.setWidth( size.height() * vaspect ); |
| 1028 | } |
| 1029 | else if (vaspect > drawVideoBoundsAspect && vaspect > 0.0) |
| 1030 | { |
| 1031 | // The aspect ratio of the preview window is smaller than that of the image |
| 1032 | // being displayed. This can happen when trying to display a 16:9 image |
| 1033 | // in a 4:3 window. We need to calculate the height of the image. |
| 1034 | size.setHeight( size.width() / vaspect ); |
| 1035 | } |
| 1036 | |
| 1037 | size.setHeight(((size.height() + 7) / 8) * 8); |
| 1038 | size.setWidth( ((size.width() + 7) / 8) * 8); |
| 1039 | |
| 1040 | hoffset = (drawVideoBounds.width() - size.width()) / 2; |
| 1041 | voffset = (drawVideoBounds.height() - size.height()) / 2; |
| 1042 | |
| 1043 | if (hoffset > 0) |
| 1044 | { |
| 1045 | QSize barsize = drawVideoBounds.size(); |
| 1046 | barsize.setWidth(hoffset); |
| 1047 | QPixmap qpm(barsize); |
| 1048 | qpm.fill(black); |
| 1049 | p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y(), qpm); |
| 1050 | p->drawPixmap(drawVideoBounds.x()+drawVideoBounds.width()-hoffset, drawVideoBounds.y(), qpm); |
| 1051 | } |
| 1052 | if (voffset > 0) |
| 1053 | { |
| 1054 | QSize barsize = drawVideoBounds.size(); |
| 1055 | barsize.setHeight(voffset); |
| 1056 | QPixmap qpm(barsize); |
| 1057 | qpm.fill(black); |
| 1058 | p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y(), qpm); |
| 1059 | p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y()+drawVideoBounds.height()-(voffset-1), qpm); |
| 1060 | } |
| 1061 | |
| 1062 | // Scale and draw the preview image |
| 1063 | QImage previewImg = temp.convertToImage(); |
| 1064 | QImage previewImgScaled = previewImg.smoothScale (size.width(), size.height()); |
1116 | | size.setHeight((int) ceil(size.height() * (saspect / vaspect) * hmult)); |
| 1167 | |
| 1168 | if ( drawVideoBoundsAspect > vaspect) { |
| 1169 | // The aspect ratio of the preview window is greater than that of the image |
| 1170 | // being displayed. This can happen when trying to display a 4:3 image |
| 1171 | // in a 16:9 window. We need to calculate the width of the image. |
| 1172 | size.setWidth( size.height() * vaspect ); |
| 1173 | |
| 1174 | } else if (vaspect > drawVideoBoundsAspect && vaspect > 0.0) { |
| 1175 | // The aspect ratio of the preview window is smaller than that of the image |
| 1176 | // being displayed. This can happen when trying to display a 16:9 image |
| 1177 | // in a 4:3 window. We need to calculate the height of the image |
| 1178 | size.setHeight( size.width() / vaspect ); |
| 1179 | } |
| 1180 | |
1123 | | if (img.height() < drawVideoBounds.height()) |
1124 | | video_y = drawVideoBounds.y() + |
1125 | | (drawVideoBounds.height() - img.height())/2; |
1126 | | else |
1127 | | video_y = drawVideoBounds.y(); |
| 1187 | if (hoffset > 0 || voffset > 0) { |
| 1188 | if (previewVideoAspect != vaspect) { |
| 1189 | // If the Aspect ratio has changed draw the black bars either above and below the image, |
| 1190 | // or on either side of the image. |
| 1191 | previewVideoAspect = vaspect; |
| 1192 | |
| 1193 | if (hoffset > 0) { |
| 1194 | QSize barsize = drawVideoBounds.size(); |
| 1195 | barsize.setWidth(hoffset); |
| 1196 | QPixmap qpm(barsize); |
| 1197 | qpm.fill(black); |
| 1198 | p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y(), qpm); |
| 1199 | p->drawPixmap(drawVideoBounds.x()+drawVideoBounds.width()-hoffset, drawVideoBounds.y(), qpm); |
| 1200 | } |
| 1201 | if (voffset > 0) { |
| 1202 | QSize barsize = drawVideoBounds.size(); |
| 1203 | barsize.setHeight(voffset); |
| 1204 | QPixmap qpm(barsize); |
| 1205 | qpm.fill(black); |
| 1206 | p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y(), qpm); |
| 1207 | p->drawPixmap(drawVideoBounds.x(), drawVideoBounds.y()+drawVideoBounds.height()-voffset, qpm); |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | const QImage &img = previewVideoNVP->GetARGBFrame(size); |