Re: scaling bitmaps

From: Don Dietrick <dietrick@bbn.com>
Date: Wed May 16 2001 - 10:56:42 EDT

Hi Mark,

I'd look at two things:

1. Make sure you regenerate the omgraphic list after scaling the
OMRaster.

2. When the OMRaster is build using an Image/ImageIcon (I don't know if
you are doing this) that internal version of the Image in the OMRaster
is replaced by the scaled version. You'll want to refresh the original
image in the OMRaster if you plan on calling scaleTo() on the
OMRasterObject again.

If the image isn't ready, the OMRaster will complain about it in a loud
but semi-obscure manner. You'll know. I don't think this is happening,
because I only ever see it when the source image is inaccessable to the
OMRaster.

The hash table is a good idea. You can even scale the image
independently from the OMRaster, and then just set the image in the
rasters before regenerating, without specifically scaling each one.

Cheers,

Don

Mark Bucciarelli wrote:
>
> I'm trying to scale the bitmaps I'm using for a location layer, but I'm
> not having much luck. With the following snippet in the layer.prepare()
> method I get no graphics at all. With it commented out, the bitmaps
> are fine (but large).
>
> // scale images
> float factor = 1f;
> for (int i = 0; i < omGraphicList.size(); i++)
> {
> Location graphic = (Location) omGraphicList.get(i);
> OMRaster raster = (OMRaster) graphic.getLocationMarker();
> int h = Math.round(raster.getHeight() * factor);
> int w = Math.round(raster.getWidth() * factor);
> raster.scaleTo(w, h, OMRasterObject.FAST_SCALING);
> }
>
> Where should I put this code? I'm going to try the projection
> changed event next ... but I'd like to know why the above doesn't
> work--I'll read up on the ImageIcon stuff in Swing; I'm guessing
> it's because the image isn't "ready" yet.
>
> Also, I was wondering if it would be more efficient to store one
> version of each unique graphic with the handler, perhaps in a hash
> table keyed by the file name. If I have 100 locations, where 25 use
> one graphic and 75 use another, wouldn't it be much more memory
> efficient to store one copy of each and then link to that graphic?
> Especially since when scaling URL Rasters, you should to save a copy
> of the original scale.
>
> --
> Mark Bucciarelli <mbucciarelli@peregrine.com>
> R&D, Boston
> Peregrine Systems, Inc.
> http://www.peregrine.com
> (413) 253-0020
>
>
>
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe openmap-users"]

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Donald Dietrick  dietrick@bbn.com (617)873-3031 [FAX]4328
BBN Technologies, 10 Moulton Street, Cambridge, MA 02138
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Wed May 16 10:53:38 2001

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:31 EDT