Okay...
I have a dictionary of textures in the function draw
Is there a way to convert all the textures in a dictionary into one bigtexture ?

var layersCopy = {};
var layersCopyMousePoint;

func _process(delta):
	mXG = snapped(  get_global_mouse_position().x, 32 );
	mYG = snapped(  get_global_mouse_position().y, 32 );
	mGpos = Vector2 (mXG, mYG);


		if ( toolCheck == 1 && mouseInEditor == true && top_2D.button_pressed == true  ):
			SelctRect = Rect2(mXG, mYG, 32*11, 32*11 );

			if ( Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) && SelctPress == true ):
				SelctPress = false;

			elif ( ! Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) && SelctPress == false ):
				SelctPress = true;
				layersCopy = layers.Lnum[ layerPOS ]; ############### MOUSE ICON COPY/PASTE
				layersCopyMousePoint = mGpos; ################## 
				print(layersCopy)

func _draw():
	
	if ( toolCheck == 1 && mouseInEditor == true ):
		draw_rect( SelctRect, Color.YELLOW, false, 2 );
		draw_string (font, Vector2(mXG, mYG-30), "mGpos2: " + str(mGpos))
		if ( SelctText != null ):
			for i in layersCopy:
				draw_texture( layersCopy[i], mGpos + i - layersCopyMousePoint  );

print(layersCopy):
{ (224, 96): <ImageTexture#-9223367288483132947>, (224, 128): <ImageTexture#-9223367288432801300>, (224, 160): <ImageTexture#-9223367288382469653>, (224, 192): <ImageTexture#-9223367288332138006>, (224, 224): <ImageTexture#-9223367288281806359>, (256, 96): <ImageTexture#-9223367288231474712>, (256, 128): <ImageTexture#-9223367288181143065>, (256, 160): <ImageTexture#-9223367288130811418>, (256, 192): <ImageTexture#-9223367288080479771>, (256, 224): <ImageTexture#-9223367288030148124>, (288, 96): <ImageTexture#-9223367287979816487>, (288, 128): <ImageTexture#-9223367287929484846>, (288, 160): <ImageTexture#-9223367287879153218>, (288, 192): <ImageTexture#-9223367287828821804>, (288, 224): <ImageTexture#-9223367287778513138>, (320, 96): <ImageTexture#-9223367287728158479>, (320, 128): <ImageTexture#-9223367287677826845>, (320, 160): <ImageTexture#-9223367287627495029>, (320, 192): <ImageTexture#-9223367287577163333>, (320, 224): <ImageTexture#-9223367287526832050> }

  • Toxe replied to this.

    jonSS Is it causing any slowdowns or take too long?

      Toxe And why are you asking that ?
      Do you have a problem with something ? What if it is ? do you thing it is ?
      Is there something bodering you , that you dont want to say ?

      • Toxe replied to this.

        jonSS Why are you so aggressive? I was just asking. 😆 There have been a lot of people on this forum in the past asking about performance and premature optimizations when in reality it doesn't really matter.

        Only after I commented did I watch your video (because I forgot about it or didn't really notice it or whatever) and saw what you were doing. But I simply left my comment as it was and looked a bit on the Interwebs for a solution.

        So relax, it's all good.

        Toxe well... thanks for the reply. For a moment it kind of sounded like you were talking about too many images on screen at the same time...

        well... that is the point... the "blit" functions dont work.
        For some reason none of this uncandy stuff thats on the manual ever does.

        I just have this 2 "textures" or "images" ?

        				print("combined_texture: " + str(combined_texture) );
        				print("drawText: " + str(drawText)); 

        print log:

        combined_texture: <ImageTexture#-9223369811558328444>
        drawText: <ImageTexture#-9223369824476784752>

        "drawText" is a normal image. " texture region created from another image "
        "combined_texture" is an image made by combining 2 "blit_rect" togheter.

        has you can see by the print "combined_texture" and "drawText" are all made by this same stuff : -> " <ImageTexture#something> ".

        :
        when i use "drawText" everything works fine:

        func _draw():
        	draw_texture(drawText, mouseGlobalpos );

        But "combined_texture" everything in func draw disapears from the screen, i get no errors / nothing:

        func _draw():
        	draw_texture(combined_texture, mouseGlobalpos  );

        Iam not sure the "blit" functions, are used to combine 2 images into 1. Or anyone has ever used it like that...
        Maybe the only way to know what they do is creating a new empty project and use them on 2 sprites, so far ive had no results in getting them to work.

          jonSS Blitting works just fine. You're likely using it incorrectly. We cannot tell for sure though because you haven't shown any of your actual blitting code.

          jonSS Not sure if this is exactly what you want to achieve but I made a quick test project.

          See here for the details: https://godotforums.org/d/40857-combine-smaller-sprite2d-or-images-into-one-big-sprite2dimage

          func combine_images(sprites: Array[Sprite2D]) -> void:
              assert(!sprites.is_empty())
          
              var format := sprites[0].texture.get_image().get_format()
              var bounding_box := calc_bounding_box(sprites)
          
              assert(sprites.all(func(sprite: Sprite2D) -> bool: return sprite.texture.get_image().get_format() == format))
              assert(bounding_box.size.x > 0 and bounding_box.size.y > 0)
          
              var image := Image.create(int(bounding_box.size.x), int(bounding_box.size.y), false, format)
          
              for sprite in sprites:
                  image.blend_rect(sprite.texture.get_image(), Rect2i(Vector2i.ZERO, sprite.texture.get_image().get_size()), get_sprite_rect(sprite).position - bounding_box.position)
          
              var texture := ImageTexture.create_from_image(image)
          
              if combined_sprite:
                  combined_sprite.queue_free()
          
              combined_sprite = Sprite2D.new()
              combined_sprite.texture = texture
              combined_sprite.position = Vector2(600, 300)
              add_child(combined_sprite)