Hi Even, I have 1.8, and I was getting a grey image earlier but I guess by adding the Integer.SIZE in the byte array size made it work, but honestly I am not sure how its working now, further I was wondering if GDAL can leverage from JAI`s DiskMemImage class, because if I have to write a bigtiff as big as 12GB, Its impossible to work with Memory Raster.
regards, Imran On Tue, Jun 12, 2012 at 11:14 PM, Even Rouault <even.roua...@mines-paris.org> wrote: > Le mardi 12 juin 2012 13:31:44, Imran Rajjad a écrit : >> Dear List, >> >> Have been trying to write raster from one file format e.g. BMP into a >> tiff file which will eventually become a BIGTiff. The current output >> is a grey image whereas the output should be RGB. The GeoTiFF is not >> accepting bands for some reasons, To write a multiband geoTiff do we >> require to add each band separately or is there something missing in >> the below code snippet? >> >> gdal.AllRegister(); >> Driver driver = gdal.GetDriverByName("GTiff"); >> Dataset dst = driver.Create("d:\\test.tif", 256, >> 256,3,gdalconst.GDT_Byte); Dataset src = gdal.Open("d:\\test.bmp"); >> >> >> byte[] outputPixels = new byte[src.GetRasterXSize() * >> src.GetRasterYSize() * src.getRasterCount()*Integer.SIZE]; >> src.ReadRaster(0, 0, src.getRasterXSize(), >> src.getRasterYSize(), >> src.getRasterXSize(), src.getRasterYSize(), gdalconst.GDT_Byte, >> outputPixels, null, 0); >> dst.WriteRaster(0, 0, src.getRasterXSize(), >> src.getRasterYSize(), >> src.getRasterXSize(), src.getRasterYSize(), gdalconst.GDT_Byte, >> outputPixels, null, 0); >> dst.FlushCache(); >> dst.delete(); >> src.delete(); >> > > I've just tested the above snippet with a 256x256 image and it works as > expected. Not sure why you have a problem. Do you use a recent GDAL version, > let's say 1.9 ? -- I.R _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev