37 , m_exportMode(export_mode)
42 dimensionsGroupBox->setVisible(
false);
43 fileSizeDescLabel->setVisible(
false);
44 fileSizeLabel->setVisible(
false);
45 bppDescLabel->setVisible(
false);
46 bppLabel->setVisible(
false);
89 int fileSize = fileSizeLabel->text().toInt(&ok);
92 int w = widthInput->value();
93 int h = heightInput->value();
95 quint32 depth = bppLabel->text().toUInt(&ok);
98 QString old_status = statusLabel->text();
100 int bytesPerPixel = depth / 8;
101 int dataSize = w * h * bytesPerPixel;
103 bool status_ok =
false;
105 QString fileMismatch = i18n(
"Input does not match file size");
106 if (w == 0 && h == 0) {
107 statusLabel->setText(i18n(
"Please specify width and height"));
110 statusLabel->setText(i18n(
"Please specify width"));
113 statusLabel->setText(i18n(
"Please specify height"));
115 else if (dataSize != fileSize) {
116 statusLabel->setText(fileMismatch);
119 statusLabel->setText(
"");
123 if (old_status.compare(statusLabel->text()) != 0) {
142 quint32 w = widthInput->value();
143 quint32 h = heightInput->value();
146 quint32 fileSize = fileSizeLabel->text().toUInt(&ok);
149 quint32 depth = bppLabel->text().toUInt(&ok);
152 quint32 bytesPerPixel = depth / 8;
154 w = widthInput->text().toUInt(&ok);
157 h = heightInput->text().toUInt(&ok);
160 quint32 dimensions = fileSize / bytesPerPixel;
162 if (w > 0 && h > 0) {
163 if (w * h == dimensions) {
165 widthInput->setValue(h);
166 heightInput->setValue(w);
169 else if (w == 0 && h == 0) {
170 quint32 r = (quint32)(qFloor(qSqrt(dimensions) + 0.5));
173 if (r*r == dimensions) {
174 widthInput->setValue(r);
175 heightInput->setValue(r);
180 h = dimensions / w + (dimensions % w);
181 if (w * h != dimensions) {
182 showErrorTooltip(i18n(
"Too many possible combinations. Input a width or height and try again."));
187 widthInput->setValue(w > h ? w : h);
188 heightInput->setValue(w > h ? h : w);
194 if (w > dimensions) {
198 h = dimensions / w + (dimensions % w);
199 if (w * h != dimensions) {
200 showErrorTooltip(i18n(
"Unable to calculate an appropriate height. File does not contain enough pixels to form a rectangle."));
203 heightInput->setValue(h);
206 if (h > dimensions) {
210 w = dimensions / h + (dimensions % h);
211 if (w * h != dimensions) {
212 showErrorTooltip(i18n(
"Unable to calculate an appropriate width. File does not contain enough pixels to form a rectangle."));
215 widthInput->setValue(w);