Ejemplo n.º 1
0
        protected new void doStuff()
        {
            InventoryFolder iFolder = AgentInventory.getFolder("Textures");

            iFolder = iFolder.CreateFolder(Helpers.GetUnixTime().ToString());

            Console.WriteLine("Uploading images:");

            string[] files = Directory.GetFiles(ImageDirectory, "*.tif");

            int filesUploaded = 0;

            foreach (string file in files)
            {
                byte[] j2cdata = null;
                try
                {
                    j2cdata = KakaduWrap.ReadJ2CData(file);
                } catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                if (j2cdata != null)
                {
                    Console.WriteLine(file);
                    iFolder.NewImage(Path.GetFileName(file), "ImageTool Upload", j2cdata);

                    if (++filesUploaded >= 20)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void doStuff()
        {
            if (_Put)
            {
                Console.WriteLine("Reading: " + _FileName);

                byte[] j2cdata;

                if (_Rate != 0)
                {
                    j2cdata = KakaduWrap.ReadJ2CData(_FileName, _Rate);
                }
                else
                {
                    j2cdata = KakaduWrap.ReadJ2CData(_FileName);
                }


                _Client.Inventory.DownloadInventory();

                Console.WriteLine("Connecting to your Texture folder...");
                InventoryFolder iFolder = _Client.Inventory.getFolder("Textures");

                Console.WriteLine("Uploading Texture...");
                InventoryImage image = iFolder.NewImage(_FileName, "ImageTool Upload", j2cdata);
                Console.WriteLine("Asset id = " + image.AssetID.ToStringHyphenated());
            }
            else
            {
                foreach (LLUUID ImageID in _ImageIDs)
                {
                    string FileName;
                    if (_ImageIDs.Count > 1)
                    {
                        FileName = ImageID.ToString();
                    }
                    else
                    {
                        FileName = _FileName;
                    }

                    Console.WriteLine("Downloading: " + ImageID);

                    int    start = Environment.TickCount;
                    byte[] j2cdata;

                    try
                    {
                        j2cdata = _Client.Images.RequestImage(ImageID);

                        int end = Environment.TickCount;
                        Console.WriteLine("Elapsed download time, in TickCounts: " + (end - start));

                        Console.WriteLine("Image Data Length :" + j2cdata.Length);

                        Console.WriteLine("Writing to: " + FileName + ".tif");
                        File.WriteAllBytes(FileName + ".tif", JasperWrapper.jasper_decode_j2c_to_tiff(j2cdata));

                        Console.WriteLine("Writing to: " + FileName + ".tga");
                        File.WriteAllBytes(FileName + ".tga", JasperWrapper.jasper_decode_j2c_to_tga(j2cdata));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("ERROR: Can't download image :: " + e.Message);
                    }
                }
            }

            Console.WriteLine("Done...");
        }