python imaging library - HowTo put region of Pyglet image into PIL Image? -


My app reads the frame from the video (using pagettes), removes a 'strip' (i.e. field - to full width 1 to 6) Video line), then pastes each bar (adds it) in an image which can later be written as a * .png file.

The problem is that Pyglet GL images are stored in graphics memory, so are very limited size. My current klunky workaround (ie within the pyglet GL size limit) to be used as small tiles to create a PNG image, when the tile is full, it is writing to a * png file, back in that Read a PIL as an image file, then paste the last image / tile image to the PIL file * PNG file.

I think it's a PIL image-friendly format should be possible to convert pyglet- GL bar, and paste / attached directly Last PIL image, thus tile There is no need of business, which complains of many things, and its effect is influenced.

But I do not know that strip data can to get as a paste PIL image I is converted to a variety of requests differently, but I never with the herd Do not run

I know it's a bad form to answer the same question, but I have an answer It may be useful to others, so here it is ...

nextframe = source.get_next_video_frame () # get the first video frame
nextframe while = none: # Return EOF None on

  ### Extract bar data, Patch dialogue for favorable form of image, Travo image # bar = nextframe paste ITN. get_region (0, (vid_frame_h // 2) - (strip_h // 2), strip_w, strip_h) Remove # from the frame strip_image_data = strip.get_image_data bar () strip_data = strip_image_data.get_data (strip_image_data.format, strip_image_data.pitch) strip_Image = Image.frombuffer ( "RGB", (strip_w, strip_h), Strip_deta) travo_image.paste (strip_image, (0, travo_filled_to, strip_w, travo_filled_to + strip_h)) # paste strip image travo_image travo_filled_to = travo_filled_to + # updated travo_filled indicator strip_h nextframe = source.get_next_video_frame () # find the next video frame (no EOF returns)  

to end "while nextframe = No:"


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -