[Gdal-dev] Display help

Gauthier,Jean-Philippe [CMC] Jean-Philippe.Gauthier at ec.gc.ca
Thu Sep 20 11:14:21 EDT 2007


	If you are using OpenGL, just use the glPixelTrensferf functions to do the scaling and bias, something like that:

         glEnable(GL_COLOR_TABLE);
         glColorTable(GL_COLOR_TABLE,GL_RGBA,256,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)Band->Spec->Map->Color);

         for (nc=0;nc<Band->Def->NC;nc++) {
            switch(Band->Def->Type) {
               case TD_UByte:  Band->Tex.Scale[nc]=((0x1<<8)-1)/(Band->Spec->Map->Max[nc]-Band->Spec->Map->Min[nc]);
                               Band->Tex.Bias[nc]=-Band->Spec->Map->Min[nc]/((0x1<<8)-1);
                              break;
               case TD_Byte:   Band->Tex.Scale[nc]=((0x1<<7)-1)/(Band->Spec->Map->Max[nc]-Band->Spec->Map->Min[nc]);
                               Band->Tex.Bias[nc]=-Band->Spec->Map->Min[nc]/((0x1<<7)-1);
                               break;
               case TD_UInt16: Band->Tex.Scale[nc]=((0x1<<16)-1)/(Band->Spec->Map->Max[nc]-Band->Spec->Map->Min[nc]);
                               Band->Tex.Bias[nc]=-Band->Spec->Map->Min[nc]/((0x1<<16)-1);
                               break;
               case TD_Int16:  Band->Tex.Scale[nc]=((0x1<<15)-1)/(Band->Spec->Map->Max[nc]-Band->Spec->Map->Min[nc]);
                               Band->Tex.Bias[nc]=-Band->Spec->Map->Min[nc]/((0x1<<15)-1);
                               break;
               case TD_UInt32:
               case TD_Int32:
               case TD_Float32:
               case TD_Float64: Band->Tex.Scale[nc]=1.0/(Band->Spec->Map->Max[nc]-Band->Spec->Map->Min[nc]);
                                Band->Tex.Bias[nc]=-Band->Spec->Map->Min[nc];
                                break;
            }
            glPixelTransferf(sc[nc],Band->Tex.Scale[nc]);
            glPixelTransferf(bc[nc],Band->Tex.Bias[nc]*Band->Tex.Scale[nc]);
         }
      }


================================================================
Jean-Philippe Gauthier Bilodeau		Direction des opérations
Analyste Programmeur Scientifique		Centre Météorologique Canadien
Tel : (514) 421-4642				2121 Route Transcanadienne
Fax: (514) 421-4679				Dorval,Québec
Email: Jean-Philippe.Gauthier at ec.gc.ca	H9P 1J3

 

-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org [mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Frank Warmerdam
Sent: 20 September, 2007 11:49
To: Christiaan Janssen
Cc: gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] Display help

Christiaan Janssen wrote:
> Could anyone give me some suggestions on what would be the appropriate 
> method for displaying raster data with GDAL. I'm currently using 
> openGL which is all fine but I have an issue dealing with imagery 
> thats over 8 bit. Is there a way to have GDAL scale the sample values 
> or is this something I would have to do manually. Thanks

Christiaan,

Generally speaking I'd suggest you rescale the data as a post processing step after reading it with GDALRasterIO().  There are GDAL calls to get min/max and stats information that may be helpful to you in deciding on a scaling strategy.

Best regards,
-- 
---------------------------------------+--------------------------------
---------------------------------------+------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev




More information about the Gdal-dev mailing list