title: How to create a pygame surface from a numpy array of float32?
body: <p>I have a piece of code that works using </p>
  
  <pre><code>my_surface = pygame.image.load('some_image.png')
  </code></pre>
  
  <p>This returns a pygame surface. I'd like to use the same code everywhere else but instead pass in a numpy array. (Actually, I'm going to have an if statement that determines whether we have an array or a path to an image. In either case the function has to return the same type of object, a pygame surface. It already works using the above code. Now I have to add a second way of generating the same object if the script is being used differently.) I have tried using</p>
  
  <pre><code>my_surface = pygame.pixelcopy.make_surface(my_array)
  </code></pre>
  
  <p>but the problem is that this function requires an INTEGER array. My array is a float32. I can force it through by passing the array like so</p>
  
  <pre><code>(my_array*10000).astype(int)
  </code></pre>
  
  <p>But when I display it later it looks like garbage (imagine my surprise). So my question is, how do we create a pygame surface elegantly out of a numpy array of floats?</p>