Sign in to follow this  

Storing image file in Python PIL as an unsigned char*

Recommended Posts

I'm trying to convert an image file data from Python PIL to an unsigned char*. Here's how i read the image data from python: im = filename ) data = list( im.getdata() ) Now, i want this data in unsigned char* so that i can use it in my c++ codes for texture mapping, any help please?

Share this post

Link to post
Share on other sites
Look for array in the python-docs

from array import array
import Image

im ="test.bmp" )
data = list( im.getdata() )

#here is your data as an array of unsigned char

#let's write it to a file

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this