コード例 #1
0
 public override ImageData Read(IBinaryStream stream, ImageMetaData info)
 {
     using (var reader = new PgdReader(stream, 0x1C))
     {
         var data = reader.Unpack00();
         using (var tga = new BinMemoryStream(data, stream.Name))
         {
             var tga_info = Tga.ReadMetaData(tga);
             if (null == tga_info)
             {
                 throw new InvalidFormatException();
             }
             tga.Position = 0;
             return(Tga.Read(tga, tga_info));
         }
     }
 }
コード例 #2
0
        public void UpdateSky(string zoneName)
        {
            Tga tex = assetManager.LoadPackAsset <Tga>($"sky_{zoneName.ToLower()}_dome_1200.tga");

            if (tex == null)
            {
                Debug.LogWarning($"Could not find Sky for Zone {zoneName}. Using Default.");
                return;
            }

            Texture2D skybox = new Texture2D(tex.Width, tex.Height, TextureFormat.ARGB32, false);

            skybox.SetPixels32(tex.Data);
            skybox.Apply(false, true);

            skyboxInstance.SetTexture("_Tex", skybox);
            DynamicGI.UpdateEnvironment();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: matsuko/Msticky
            public static Bitmap Read(String file)
            {
                Bitmap bitmap;

                FileStream fs = new FileStream(file,FileMode.Open,FileAccess.Read);
                byte[] bs = new byte[fs.Length];
                fs.Read(bs, 0, bs.Length);
                fs.Close();

                Tga tga = new Tga();
                tga.header.id = bs[0];
                tga.header.colorMapType = bs[1];
                tga.header.imageType = bs[2];

                tga.header.colorMapSpecification.firstEntryIndex = (short)((short)bs[3] + (short)bs[4] * 256);
                tga.header.colorMapSpecification.colorMapLength = (short)((short)bs[5] + (short)bs[6] * 256);
                tga.header.colorMapSpecification.colorMapEntrySize = bs[7];

                tga.header.imageSpecification.xOriginOfImage = (short)((short)bs[8] + (short)bs[9] * 256);
                tga.header.imageSpecification.yOriginOfImage = (short)((short)bs[10] + (short)bs[11] * 256);
                tga.header.imageSpecification.imageWidth = (short)((short)bs[12] + (short)bs[13] * 256);
                tga.header.imageSpecification.imageHeight = (short)((short)bs[14] + (short)bs[15] * 256);
                tga.header.imageSpecification.pixelDepth = bs[16];
                tga.header.imageSpecification.imageDescriptor = bs[17];

                bitmap = new Bitmap(tga.header.imageSpecification.imageWidth, tga.header.imageSpecification.imageHeight);

                switch (tga.header.imageType)
                {
                    case (byte)ImageType.UncompressedTrueColorImage:
                        break;
                    case (byte)ImageType.RLETrueColorImage:
                        break;
                    default:
                        MessageBox.Show("Not implemented TGA Format. imageType:" + tga.header.imageType);
                        return null;
                }

                if (tga.header.colorMapSpecification.firstEntryIndex != 0 ||
                    tga.header.colorMapSpecification.colorMapLength != 0 ||
                    tga.header.colorMapSpecification.colorMapEntrySize != 0)
                {
                    MessageBox.Show("Not support TGA ColorMap. " + tga.header.colorMapSpecification);
                    return null;
                }

                if (tga.header.imageSpecification.xOriginOfImage != 0 ||
                    tga.header.imageSpecification.yOriginOfImage != 0)
                {
                    MessageBox.Show("Not support TGA origin. " + tga.header.imageSpecification);
                    return null;
                }

                PixelReader reader = tga.GetPixelReader(bs);
                if (reader == null)
                {
                    return null;
                }

                do
                {
                    bitmap.SetPixel(reader.X, reader.Y, reader.GetColor());
                } while (reader.Next());

                return bitmap;
            }