@@ -138,6 +138,7 @@ def image_to_texture2d(
138138 platform_blob : Optional [TextureSwizzler .PlatformBlobType ] = None ,
139139 flip : bool = True ,
140140) -> Tuple [bytes , TextureFormat ]:
141+ """Converts a PIL Image to Texture2D bytes."""
141142 if not isinstance (platform , BuildTarget ):
142143 platform = BuildTarget (platform )
143144
@@ -191,7 +192,7 @@ def image_to_texture2d(
191192 elif target_texture_format == TF .Alpha8 :
192193 tex_format = TF .Alpha8
193194 pil_mode = "A"
194- # R - should probably be moerged into #A, as pure R is used as Alpha
195+ # R - should probably be merged into #A, as pure R is used as Alpha
195196 # but need test data for this first
196197 elif target_texture_format in [
197198 TF .R8 ,
@@ -257,15 +258,7 @@ def get_image_from_texture2d(
257258 texture_2d : Texture2D ,
258259 flip : bool = True ,
259260) -> Image .Image :
260- """converts the given texture into PIL.Image
261-
262- :param texture_2d: texture to be converterd
263- :type texture_2d: Texture2D
264- :param flip: flips the image back to the original (all Unity textures are flipped by default)
265- :type flip: bool
266- :return: PIL.Image object
267- :rtype: Image
268- """
261+ """Converts the given Texture2D object to PIL Image."""
269262 return parse_image_data (
270263 texture_2d .get_image_data (),
271264 texture_2d .m_Width ,
@@ -288,6 +281,7 @@ def parse_image_data(
288281 platform_blob : Optional [TextureSwizzler .PlatformBlobType ] = None ,
289282 flip : bool = True ,
290283) -> Image .Image :
284+ """Converts the given image data bytes to PIL Image."""
291285 if not width or not height :
292286 return Image .new ("RGBA" , (0 , 0 ))
293287
@@ -349,9 +343,7 @@ def parse_image_data(
349343
350344
351345def swap_bytes_for_xbox (image_data : Union [bytes , bytearray , memoryview ]) -> bytearray :
352- """swaps the texture bytes
353- This is required for textures deployed on XBOX360.
354- """
346+ """Swaps the texture bytes for textures deployed on XBOX360."""
355347 image_data = bytearray (image_data )
356348 for i in range (0 , len (image_data ), 2 ):
357349 image_data [i : i + 2 ] = image_data [i : i + 2 ][::- 1 ]
0 commit comments