Skip to content

Commit

Permalink
removed scaled thumb image, it had the same size as the original thum…
Browse files Browse the repository at this point in the history
…b but this was not the reason to remove it, this image was NEVER disposed -> SWT was running very fast out of handles when moving the tour chart slider as this would create a new image for every new slider position, discovered this issue with SWT sleak
  • Loading branch information
wolfgang-ch committed Aug 2, 2020
1 parent 708f633 commit d3e09e3
Showing 1 changed file with 2 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package net.tourbook.map25.layer.marker;

import java.awt.Point;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -43,12 +42,10 @@
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.imgscalr.Scalr.Rotation;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Color;
Expand Down Expand Up @@ -275,14 +272,13 @@ private Bitmap getPhotoBitmap(final Photo photo) {
private Image getPhotoImage(final Photo photo, final int thumbSize) {

Image photoImage = null;
Image scaledThumbImage = null;

final ImageQuality requestedImageQuality = ImageQuality.THUMB;

// check if image has an loading error
final PhotoLoadingState photoLoadingState = photo.getLoadingState(requestedImageQuality);
if (photoLoadingState != PhotoLoadingState.IMAGE_IS_INVALID) {
//debugPrint("??? entering getPhotoImage"); //$NON-NLS-1$

// image is not yet loaded

// check if image is in the cache
Expand All @@ -297,43 +293,9 @@ private Image getPhotoImage(final Photo photo, final int thumbSize) {

PhotoLoadManager.putImageInLoadingQueueThumbMap(photo, requestedImageQuality, imageLoadCallback);
}

if (photoImage != null) {

final Rectangle imageBounds = photoImage.getBounds();
final int originalImageWidth = imageBounds.width;
final int originalImageHeight = imageBounds.height;

final int imageWidth = originalImageWidth;
final int imageHeight = originalImageHeight;

//final int thumbSize = PhotoLoadManager.IMAGE_SIZE_THUMBNAIL;// PhotoLoadManager.IMAGE_SIZE_LARGE_DEFAULT;
boolean isRotated = false;

final Point bestSize = ImageUtils.getBestSize(imageWidth, imageHeight, thumbSize, thumbSize);
final Rotation thumbRotation = null;
if (isRotated == false) {
isRotated = true;
//thumbRotation = getRotation();
}

scaledThumbImage = ImageUtils.resize(
_display,
photoImage,
bestSize.x,
bestSize.y,
SWT.ON,
SWT.LOW,
thumbRotation);

} else {

// wait until image is loaded
scaledThumbImage = null;
}
}

return scaledThumbImage;
return photoImage;
}

@Override
Expand Down

8 comments on commit d3e09e3

@wolfgang-ch
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@telemaxx FYI, see commit comment

@telemaxx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result is not looking good.
The thumbnails becomes really big.
due this, also the map25 view is not very responsive anymore.

i will check how to dispose and revert to sclaled images

New:
grafik

Old (708f633):
grafik

@wolfgang-ch
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wolfgang-ch
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good feature would be, that the image size could be set in the UI

@telemaxx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe that depends on original image size? my images are taken with my mobile with about 8 mpixel

@wolfgang-ch
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My image size is 20 MP

my-image-size

@telemaxx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My image size is 20 MP
ok, must have an other reason, that it looks good for you

sure, that you have tested with final 20.8?
https://sourceforge.net/p/mytourbook/discussion/622811/thread/4a805b887e/bdc3/attachment/mt-save-restore-tour-image.jpg
"removing scaled images" is only 11 days old, could it be that you have tested with an older branch?

@wolfgang-ch
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screenshot is from the released 20.8

"removing scaled images" is only 11 days old, could it be that you have tested with an older branch?

This was a last minute action, first I tried to dispose the images but then I discovered it is too complicated and "found" this easy solution, otherwise I've not published it with this major bug

An improvement for this Map could be, that the photos and markers are on the same layer because currently the markers are all above the photos and not hidden from the perspective view. In this screenshot "Albulapass" and "Strassenbelag" should be behind the nearest image.

mt-map25-2

Please sign in to comment.