Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] BufferProxy.raw problem

I've been trying for a few days now to send the pixel data of a surface using get_view() through a pipe to a c progam.
But i can't get the raw values of the rgb pixels using BufferProxy.raw...

I can see the "start" and "end" but not the "buf.raw".

I'm using python 2.7.

i tried using "array = pygame.surfarray.pixels3d(screen)", i can see it when using "print array" but the data can't go through the pipe because it is not contiguous.

Do you have any idea where i went wrong ?

Thanks !

import pygame
import os, sys, time

os.environ["SDL_VIDEODRIVER"] = "dummy"
pygame.display.set_mode((5,5), 0, 24)
screen = pygame.display.get_surface()

pygame.draw.line(screen, (200, 0, 0), (0, 0),(4,0), 1)

buf = screen.get_view('2')

# this line doesn't show anything

pipe_name = "/tmp/pgmatrix"

if os.path.exists(pipe_name):
if not os.path.exists(pipe_name):

pipe = os.open(pipe_name, os.O_WRONLY)

os.write(pipe, "start")
os.write(pipe, buf.raw)
os.write(pipe, "end")

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)