GetImageSize
How do I use Get Image Size
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
180 | GetImageSize( imageData, out texWidth, out texHeight ); | 1 |
202 | private static void GetImageSize( byte[] imageData, out int width, out int height ) | 2 |
File name: ReorderableListResources.cs
Copy
168 private static void LoadResourceAssets()
169 {
170 var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin;
171 s_Cached = new Texture2D[ skin.Length ];
172
173 for( int i = 0; i < s_Cached.Length; ++i )
174 {
175 // Get image data (PNG) from base64 encoded strings.
176 byte[] imageData = Convert.FromBase64String( skin[ i ] );
177
178 // Gather image size from image data.
179 int texWidth, texHeight;
180 GetImageSize( imageData, out texWidth, out texHeight );
181
182 // Generate texture asset.
183 var tex = new Texture2D( texWidth, texHeight, TextureFormat.ARGB32, false, true );
184 tex.hideFlags = HideFlags.HideAndDontSave;
185 tex.name = "(Generated) ReorderableList:" + i;
186 tex.filterMode = FilterMode.Point;
187 tex.LoadImage( imageData );
188
189 s_Cached[ i ] = tex;
190 }
191
192 s_LightSkin = null;
193 s_DarkSkin = null;
194 }
File name: ReorderableListResources.cs
Copy
202 private static void GetImageSize( byte[] imageData, out int width, out int height )
203 {
204 width = ReadInt( imageData, 3 + 15 );
205 height = ReadInt( imageData, 3 + 15 + 2 + 2 );
206 }
GetImageSize 132 lượt xem
Gõ tìm kiếm nhanh...