[Gdal-dev] Q

Tim Sutton tim at linfiniti.com
Fri Nov 11 20:11:39 EST 2005


Hi

On 10 Nov 2005, at 12:54, Eric Dönges wrote:

>
> Am 10.11.2005 um 10:32 schrieb Tim Sutton:
>
>> Hi
>>
>> Take a look at qgsrasterlayer.cpp in the QGIS (http://qgis.org)  
>> source code. We have already solved this problem.
>>
>> Essentially, assign each of the three bands pixels to a different  
>> variable, then create a qcolor using each as the r,g,b values.  
>> Then simply paint your pixel using that qcolor.
>>
>> OT I would be intersested to chat to you to see if a) the  
>> application you are working on is open source and b) you would be  
>> interested in combining efforts with QGIS.
>>
>> Best Regards
>>
>> Tim
>>
>> On 10 Nov 2005, at 08:42, t.laue at web.de wrote:
>>
>>> Dear all,
>>>
>>> I am currently developing a small application using Qt 4 and C++  
>>> for handling and
>>> evaluating large aerial images given in TIF / TIFF format. I am  
>>> using GDAL for image
>>> input. I am working with image overviews and image tiles for  
>>> providing a good zoom
>>> and pan performance.
>>>
>>> At the moment GDALRasterBand::RasterIO is being used for  
>>> accessing overview levels
>>> and reading small image patchs because I did not find a way how  
>>> to read from single
>>> overview levels using GDALDataset::RasterIO. Everything is  
>>> working fine as long as I
>>> am utilising gray value images with one raster band.
>>>
>>> In the case of RGB images I can employ a loop for retrieving the  
>>> data of all three raster
>>> bands from the same overview level resulting in three buffers  
>>> which contain the data. I
>>> would like to display the color image at the screen but I have no  
>>> idea how to combine
>>> them again.
>>>
>>> Is there a way to create a new dataset for adding the data read  
>>> from different bands? Is
>>> it possible to use GDALDataset to access single overview levels?  
>>> Do I have to use
>>> another method independent of GDAL to bring the three buffers  
>>> together in order to
>>> recreate a RGB image patch? Is anyone working with Qt 4 and GDAL?
>
> While RasterIO doesn't let you specify which overview to use  
> directly, I believe it
> automatically calculates the most appropriate overview to use based  
> on the source and
> destination image sizes you specify to RasterIO. The big advantage  
> of using RasterIO
> is that you can have RasterIO worry about creating packed pixel  
> formats from the color
> bands, which should be a lot faster than the method Tim suggests  
> above. This is how I
> do it:
>
> // Now, copy the raster data from the dataset.
> if (CE_None != GDALDatasetRasterIO(_dataset, GF_Read,
>                                    x, y, (int)ceilf(rect.size.width),
>                                    (int)ceilf(rect.size.height),
>                                    data, width, height, GDT_Byte,  
> bands,
> 				   &_bandMap[bandStart],
> 				   bytesPerPixel, bytesPerRow, 1))
> {
> 	NSLog(@"problem with GDALDatasetRasterIO");
>         goto done;
> }
>
> 'data' is the pointer to the memory area that should hold the  
> ARGB32 data, 'bands' is
> the number of bands in the dataset, and '_bandMap' holds an array  
> of the indexes of the
> bands in the correct order, which is alpha, red, green and blue for  
> my application.
> The 'bandStart' parameter is used to handle cases were the dataset  
> doesn't have an
> Alpha channel, in which case it is 1 instead of 0 (this allows me  
> to simplify the code
> that generates the _bandMap). bytesPerPixel is 4. Read the RasterIO  
> documentation
> for more details.
>
> Disclaimer: I've never worked with QT before, so the above may be  
> totally useless to
> you.
>

This is indeed interesting. Perhaps we can use this approach to make  
QGIS raster rendering even faster. I just need to check out to make  
qpainter accept a raw data block as populated by your routine.

That said raster rendering in QGIS is already pretty faster, though  
of course if cant harm to make it even faster eh? :-)

Many thanks for this tip!

Regards

Tim

> With kind regards,
> Eric
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev

Tim Sutton (tim at linfiniti.com)

Visit http://qgis.org for a great open source GIS application
Skype : timlinux
Jabber : timlinux at jabber.org
MSN : tim_bdworld at msn.com








More information about the Gdal-dev mailing list