-
Notifications
You must be signed in to change notification settings - Fork 3
/
bge.texture.html
3013 lines (2766 loc) · 210 KB
/
bge.texture.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Video Texture (bge.texture) — Blender Python API</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme_overrides.css" type="text/css" />
<link rel="stylesheet" href="_static/css/version_switch.css" type="text/css" />
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="canonical" href="https://upbge.org/docs/latest/api/bge.texture.html" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=715c20a1"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/version_switch.js?v=fa006b38"></script>
<script src="_static/js/theme.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Blender Python API"
href="_static/opensearch.xml"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Game Keys (bge.events)" href="bge.events.html" />
<link rel="prev" title="Rasterizer (bge.render)" href="bge.render.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home">
UPBGE 0.3+ + Blender 4.0.0 Alpha Python API
<img src="_static/upbge_logo.png" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Application Modules</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="bpy.context.html">Context Access (bpy.context)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.data.html">Data Access (bpy.data)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.msgbus.html">Message Bus (bpy.msgbus)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.ops.html">Operators (bpy.ops)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.types.html">Types (bpy.types)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.utils.html">Utilities (bpy.utils)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.path.html">Path Utilities (bpy.path)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.app.html">Application Data (bpy.app)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy.props.html">Property Definitions (bpy.props)</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Game Engine Modules</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="bge.types.html">Game Types (bge.types)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bge.logic.html">Game Logic (bge.logic)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bge.render.html">Rasterizer (bge.render)</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Video Texture (bge.texture)</a></li>
<li class="toctree-l1"><a class="reference internal" href="#ffmpeg-video-and-image-status">FFmpeg Video and Image Status</a></li>
<li class="toctree-l1"><a class="reference internal" href="#image-blending-modes">Image Blending Modes</a></li>
<li class="toctree-l1"><a class="reference internal" href="bge.events.html">Game Keys (bge.events)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bge.constraints.html">Physics Constraints (bge.constraints)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bge.app.html">Application Data (bge.app)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bgui.html">Game GUI (bgui)</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Standalone Modules</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="aud.html">Audio System (aud)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bgl.html">OpenGL Wrapper (bgl)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bl_math.html">Additional Math Functions (bl_math)</a></li>
<li class="toctree-l1"><a class="reference internal" href="blf.html">Font Drawing (blf)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bmesh.html">BMesh Module (bmesh)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bpy_extras.html">Extra Utilities (bpy_extras)</a></li>
<li class="toctree-l1"><a class="reference internal" href="freestyle.html">Freestyle Module (freestyle)</a></li>
<li class="toctree-l1"><a class="reference internal" href="gpu.html">GPU Module (gpu)</a></li>
<li class="toctree-l1"><a class="reference internal" href="gpu_extras.html">GPU Utilities (gpu_extras)</a></li>
<li class="toctree-l1"><a class="reference internal" href="idprop.types.html">ID Property Access (idprop.types)</a></li>
<li class="toctree-l1"><a class="reference internal" href="imbuf.html">Image Buffer (imbuf)</a></li>
<li class="toctree-l1"><a class="reference internal" href="mathutils.html">Math Types & Utilities (mathutils)</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">UPBGE 0.3+ + Blender 4.0.0 Alpha Python API</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Video Texture (bge.texture)</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="module-bge.texture">
<span id="video-texture-bge-texture"></span><h1>Video Texture (bge.texture)<a class="headerlink" href="#module-bge.texture" title="Link to this heading"></a></h1>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Link to this heading"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">bge.texture</span></code> module allows you to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture,
memory buffer, camera render or a mix of that.
The video and image files can be loaded from the Internet using a URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU,
allowing video effect: blue screen, color band, gray, normal map.
<code class="docutils literal notranslate"><span class="pre">bge.texture</span></code> uses FFmpeg to load images and videos.
All the formats and codecs that FFmpeg supports are supported by <code class="docutils literal notranslate"><span class="pre">bge.texture</span></code>,
including but not limited to:</p>
<ul class="simple">
<li><p>AVI</p></li>
<li><p>Ogg</p></li>
<li><p>Xvid</p></li>
<li><p>Theora</p></li>
<li><p>dv1394 camera</p></li>
<li><p>video4linux capture card (this includes many webcams)</p></li>
<li><p>videoForWindows capture card (this includes many webcams)</p></li>
<li><p>JPG</p></li>
</ul>
<section id="how-it-works">
<h3>How it works<a class="headerlink" href="#how-it-works" title="Link to this heading"></a></h3>
<p>The principle is simple: first you identify a texture on an existing object using the
<a class="reference internal" href="#bge.texture.materialID" title="bge.texture.materialID"><code class="xref py py-func docutils literal notranslate"><span class="pre">materialID()</span></code></a> function, then you create a new texture with dynamic content
and swap the two textures in the GPU.</p>
<p>The game engine is not aware of the substitution and continues to display the object as always,
except that you are now in control of the texture.</p>
<p>When the texture object is deleted, the new texture is deleted and the old texture restored.</p>
</section>
<section id="game-preparation">
<h3>Game Preparation<a class="headerlink" href="#game-preparation" title="Link to this heading"></a></h3>
<p>Before you can use the <a class="reference internal" href="#module-bge.texture" title="bge.texture"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bge.texture</span></code></a> module,
you must have objects with textures applied appropriately.</p>
<p>Imagine you want to have a television showing live broadcast programs in the game.
You will create a television object and UV-apply a different texture at the place of the screen,
for example <code class="docutils literal notranslate"><span class="pre">tv.png</span></code>. What this texture looks like is not important;
probably you want to make it dark gray to simulate power-off state.
When the television must be turned on, you create a dynamic texture from a video capture card
and use it instead of <code class="docutils literal notranslate"><span class="pre">tv.png</span></code>: the TV screen will come to life.</p>
<p>You have two ways to define textures that <code class="docutils literal notranslate"><span class="pre">bge.texture</span></code> can grab:</p>
<ul class="simple">
<li><p>Simple UV texture.</p></li>
<li><p>Blender material with image texture channel.</p></li>
</ul>
<p>Because <code class="docutils literal notranslate"><span class="pre">bge.texture</span></code> works at texture level, it is compatible with all
the Blender Game Engine’s fancy texturing features: GLSL, multi-texture, custom shaders, etc.</p>
</section>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Link to this heading"></a></h2>
<section id="basic-video-playback">
<h3>Basic Video Playback<a class="headerlink" href="#basic-video-playback" title="Link to this heading"></a></h3>
<p>Example of how to replace a texture in game with a video.
It needs to run everyframe.
To avoid any confusion with the location of the file,
we will use <a class="reference internal" href="bge.logic.html#bge.logic.expandPath" title="bge.logic.expandPath"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bge.logic.expandPath()</span></code></a> to build an absolute file name,
assuming the video file is in the same directory as the blend-file.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">bge</span>
<span class="kn">from</span> <span class="nn">bge</span> <span class="kn">import</span> <span class="n">texture</span>
<span class="kn">from</span> <span class="nn">bge</span> <span class="kn">import</span> <span class="n">logic</span>
<span class="n">cont</span> <span class="o">=</span> <span class="n">logic</span><span class="o">.</span><span class="n">getCurrentController</span><span class="p">()</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">cont</span><span class="o">.</span><span class="n">owner</span>
<span class="c1"># the creation of the texture must be done once: save the</span>
<span class="c1"># texture object in an attribute of bge.logic module makes it persistent</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">logic</span><span class="p">,</span> <span class="s1">'video'</span><span class="p">):</span>
<span class="c1"># identify a static texture by name</span>
<span class="n">matID</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">materialID</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s1">'IMvideo.png'</span><span class="p">)</span>
<span class="c1"># create a dynamic texture that will replace the static texture</span>
<span class="n">logic</span><span class="o">.</span><span class="n">video</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">Texture</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">matID</span><span class="p">)</span>
<span class="c1"># define a source of image for the texture, here a movie</span>
<span class="n">movie</span> <span class="o">=</span> <span class="n">logic</span><span class="o">.</span><span class="n">expandPath</span><span class="p">(</span><span class="s1">'//trailer_400p.ogg'</span><span class="p">)</span>
<span class="n">logic</span><span class="o">.</span><span class="n">video</span><span class="o">.</span><span class="n">source</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">VideoFFmpeg</span><span class="p">(</span><span class="n">movie</span><span class="p">)</span>
<span class="n">logic</span><span class="o">.</span><span class="n">video</span><span class="o">.</span><span class="n">source</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="kc">True</span>
<span class="c1"># Note that we can change the ``Texture`` source at any time.</span>
<span class="c1"># Suppose we want to switch between two movies during the game:</span>
<span class="n">logic</span><span class="o">.</span><span class="n">mySources</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">VideoFFmpeg</span><span class="p">(</span><span class="s1">'movie1.avi'</span><span class="p">)</span>
<span class="n">logic</span><span class="o">.</span><span class="n">mySources</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">VideoFFmpeg</span><span class="p">(</span><span class="s1">'movie2.avi'</span><span class="p">)</span>
<span class="c1">#And then assign (and reassign) the source during the game</span>
<span class="n">logic</span><span class="o">.</span><span class="n">video</span><span class="o">.</span><span class="n">source</span> <span class="o">=</span> <span class="n">logic</span><span class="o">.</span><span class="n">mySources</span><span class="p">[</span><span class="n">movieSel</span><span class="p">]</span>
<span class="c1"># quick off the movie, but it wont play in the background</span>
<span class="n">logic</span><span class="o">.</span><span class="n">video</span><span class="o">.</span><span class="n">source</span><span class="o">.</span><span class="n">play</span><span class="p">()</span>
<span class="c1"># Video playback is not a background process: it happens only when we refresh the texture.</span>
<span class="c1"># So you need to call this function every frame to ensure update of the texture.</span>
<span class="n">logic</span><span class="o">.</span><span class="n">video</span><span class="o">.</span><span class="n">refresh</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="texture-replacement">
<h3>Texture Replacement<a class="headerlink" href="#texture-replacement" title="Link to this heading"></a></h3>
<p>Example of how to replace a texture in game with an external image.
<code class="docutils literal notranslate"><span class="pre">createTexture()</span></code> and <code class="docutils literal notranslate"><span class="pre">removeTexture()</span></code> are to be called from a
module Python Controller.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">bge</span> <span class="kn">import</span> <span class="n">logic</span>
<span class="kn">from</span> <span class="nn">bge</span> <span class="kn">import</span> <span class="n">texture</span>
<span class="k">def</span> <span class="nf">createTexture</span><span class="p">(</span><span class="n">cont</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Create a new Dynamic Texture"""</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">cont</span><span class="o">.</span><span class="n">owner</span>
<span class="c1"># get the reference pointer (ID) of the internal texture</span>
<span class="n">ID</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">materialID</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s1">'IMoriginal.png'</span><span class="p">)</span>
<span class="c1"># create a texture object</span>
<span class="n">object_texture</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">Texture</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">ID</span><span class="p">)</span>
<span class="c1"># create a new source with an external image</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">logic</span><span class="o">.</span><span class="n">expandPath</span><span class="p">(</span><span class="s2">"//newtexture.jpg"</span><span class="p">)</span>
<span class="n">new_source</span> <span class="o">=</span> <span class="n">texture</span><span class="o">.</span><span class="n">ImageFFmpeg</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
<span class="c1"># the texture has to be stored in a permanent Python object</span>
<span class="n">logic</span><span class="o">.</span><span class="n">texture</span> <span class="o">=</span> <span class="n">object_texture</span>
<span class="c1"># update/replace the texture</span>
<span class="n">logic</span><span class="o">.</span><span class="n">texture</span><span class="o">.</span><span class="n">source</span> <span class="o">=</span> <span class="n">new_source</span>
<span class="n">logic</span><span class="o">.</span><span class="n">texture</span><span class="o">.</span><span class="n">refresh</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">removeTexture</span><span class="p">(</span><span class="n">cont</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Delete the Dynamic Texture, reversing back the final to its original state."""</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">del</span> <span class="n">logic</span><span class="o">.</span><span class="n">texture</span>
<span class="k">except</span><span class="p">:</span>
<span class="k">pass</span>
</pre></div>
</div>
</section>
<section id="video-capture-with-decklink">
<h3>Video Capture with DeckLink<a class="headerlink" href="#video-capture-with-decklink" title="Link to this heading"></a></h3>
<p>Video frames captured with DeckLink cards have pixel formats that are generally not directly
usable by OpenGL, they must be processed by a shader. The three shaders presented here should
cover all common video capture cases.</p>
<p>This file reflects the current video transfer method implemented in the Decklink module:
whenever possible the video images are transferred as float texture because this is more
compatible with GPUs. Of course, only the pixel formats that have a correspondent GL format
can be transferred as float. Look for fg_shaders in this file for an exhaustive list.</p>
<p>Other pixel formats will be transferred as 32 bits integer red-channel texture but this
won’t work with certain GPU (Intel GMA); the corresponding shaders are not shown here.
However, it should not be necessary to use any of them as the list below covers all practical
cases of video capture with all types of Decklink product.</p>
<p>In other words, only use one of the pixel format below and you will be fine. Note that depending
on the video stream, only certain pixel formats will be allowed (others will throw an exception).
For example, to capture a PAL video stream, you must use one of the YUV formats.</p>
<p>To find which pixel format is suitable for a particular video stream, use the ‘Media Express’
utility that comes with the Decklink software : if you see the video in the ‘Log and Capture’
Window, you have selected the right pixel format and you can use the same in Blender.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>These shaders only decode the RGB channel and set the alpha channel to a fixed
value (look for color.a = ). It’s up to you to add postprocessing to the color.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>These shaders are compatible with 2D and 3D video stream.</p>
</div>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">bge</span>
<span class="kn">from</span> <span class="nn">bge</span> <span class="kn">import</span> <span class="n">logic</span>
<span class="kn">from</span> <span class="nn">bge</span> <span class="kn">import</span> <span class="n">texture</span> <span class="k">as</span> <span class="n">vt</span>
<span class="c1"># The default vertex shader, because we need one</span>
<span class="c1">#</span>
<span class="n">VertexShader</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2">#version 130</span>
<span class="s2"> void main()</span>
<span class="s2"> {</span>
<span class="s2"> gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;</span>
<span class="s2"> gl_TexCoord[0] = gl_MultiTexCoord0;</span>
<span class="s2"> }</span>
<span class="s2">"""</span>
<span class="c1"># For use with RGB video stream: the pixel is directly usable</span>
<span class="c1">#</span>
<span class="n">FragmentShader_R10l</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2"> #version 130</span>
<span class="s2"> uniform sampler2D tex;</span>
<span class="s2"> // stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)</span>
<span class="s2"> uniform float stereo;</span>
<span class="s2"> // eye = 0.0 for the left eye, 0.5 for the right eye</span>
<span class="s2"> uniform float eye;</span>
<span class="s2"> void main(void)</span>
<span class="s2"> {</span>
<span class="s2"> vec4 color;</span>
<span class="s2"> float tx, ty;</span>
<span class="s2"> tx = gl_TexCoord[0].x;</span>
<span class="s2"> ty = eye+gl_TexCoord[0].y*stereo;</span>
<span class="s2"> color = texture(tex, vec2(tx,ty));</span>
<span class="s2"> color.a = 0.7;</span>
<span class="s2"> gl_FragColor = color;</span>
<span class="s2"> }</span>
<span class="s2">"""</span>
<span class="c1"># For use with YUV video stream</span>
<span class="c1">#</span>
<span class="n">FragmentShader_2vuy</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2"> #version 130</span>
<span class="s2"> uniform sampler2D tex;</span>
<span class="s2"> // stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)</span>
<span class="s2"> uniform float stereo;</span>
<span class="s2"> // eye = 0.0 for the left eye, 0.5 for the right eye</span>
<span class="s2"> uniform float eye;</span>
<span class="s2"> void main(void)</span>
<span class="s2"> {</span>
<span class="s2"> vec4 color;</span>
<span class="s2"> float tx, ty, width, Y, Cb, Cr;</span>
<span class="s2"> int px;</span>
<span class="s2"> tx = gl_TexCoord[0].x;</span>
<span class="s2"> ty = eye+gl_TexCoord[0].y*stereo;</span>
<span class="s2"> width = float(textureSize(tex, 0).x);</span>
<span class="s2"> color = texture(tex, vec2(tx, ty));</span>
<span class="s2"> px = int(floor(fract(tx*width)*2.0));</span>
<span class="s2"> switch (px) {</span>
<span class="s2"> case 0:</span>
<span class="s2"> Y = color.g;</span>
<span class="s2"> break;</span>
<span class="s2"> case 1:</span>
<span class="s2"> Y = color.a;</span>
<span class="s2"> break;</span>
<span class="s2"> }</span>
<span class="s2"> Y = (Y - 0.0625) * 1.168949772;</span>
<span class="s2"> Cb = (color.b - 0.0625) * 1.142857143 - 0.5;</span>
<span class="s2"> Cr = (color.r - 0.0625) * 1.142857143 - 0.5;</span>
<span class="s2"> color.r = Y + 1.5748 * Cr;</span>
<span class="s2"> color.g = Y - 0.1873 * Cb - 0.4681 * Cr;</span>
<span class="s2"> color.b = Y + 1.8556 * Cb;</span>
<span class="s2"> color.a = 0.7;</span>
<span class="s2"> gl_FragColor = color;</span>
<span class="s2"> }</span>
<span class="s2">"""</span>
<span class="c1"># For use with high resolution YUV</span>
<span class="c1">#</span>
<span class="n">FragmentShader_v210</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2"> #version 130</span>
<span class="s2"> uniform sampler2D tex;</span>
<span class="s2"> // stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)</span>
<span class="s2"> uniform float stereo;</span>
<span class="s2"> // eye = 0.0 for the left eye, 0.5 for the right eye</span>
<span class="s2"> uniform float eye;</span>
<span class="s2"> void main(void)</span>
<span class="s2"> {</span>
<span class="s2"> vec4 color, color1, color2, color3;</span>
<span class="s2"> int px;</span>
<span class="s2"> float tx, ty, width, sx, dx, bx, Y, Cb, Cr;</span>
<span class="s2"> tx = gl_TexCoord[0].x;</span>
<span class="s2"> ty = eye+gl_TexCoord[0].y*stereo;</span>
<span class="s2"> width = float(textureSize(tex, 0).x);</span>
<span class="s2"> // to sample macro pixels (6 pixels in 4 words)</span>
<span class="s2"> sx = tx*width*0.25+0.01;</span>
<span class="s2"> // index of display pixel in the macro pixel 0..5</span>
<span class="s2"> px = int(floor(fract(sx)*6.0));</span>
<span class="s2"> // increment as we sample the macro pixel</span>
<span class="s2"> dx = 1.0/width;</span>
<span class="s2"> // base x coord of macro pixel</span>
<span class="s2"> bx = (floor(sx)+0.01)*dx*4.0;</span>
<span class="s2"> color = texture(tex, vec2(bx, ty));</span>
<span class="s2"> color1 = texture(tex, vec2(bx+dx, ty));</span>
<span class="s2"> color2 = texture(tex, vec2(bx+dx*2.0, ty));</span>
<span class="s2"> color3 = texture(tex, vec2(bx+dx*3.0, ty));</span>
<span class="s2"> switch (px) {</span>
<span class="s2"> case 0:</span>
<span class="s2"> case 1:</span>
<span class="s2"> Cb = color.b;</span>
<span class="s2"> Cr = color.r;</span>
<span class="s2"> break;</span>
<span class="s2"> case 2:</span>
<span class="s2"> case 3:</span>
<span class="s2"> Cb = color1.g;</span>
<span class="s2"> Cr = color2.b;</span>
<span class="s2"> break;</span>
<span class="s2"> default:</span>
<span class="s2"> Cb = color2.r;</span>
<span class="s2"> Cr = color3.g;</span>
<span class="s2"> break;</span>
<span class="s2"> }</span>
<span class="s2"> switch (px) {</span>
<span class="s2"> case 0:</span>
<span class="s2"> Y = color.g;</span>
<span class="s2"> break;</span>
<span class="s2"> case 1:</span>
<span class="s2"> Y = color1.b;</span>
<span class="s2"> break;</span>
<span class="s2"> case 2:</span>
<span class="s2"> Y = color1.r;</span>
<span class="s2"> break;</span>
<span class="s2"> case 3:</span>
<span class="s2"> Y = color2.g;</span>
<span class="s2"> break;</span>
<span class="s2"> case 4:</span>
<span class="s2"> Y = color3.b;</span>
<span class="s2"> break;</span>
<span class="s2"> default:</span>
<span class="s2"> Y = color3.r;</span>
<span class="s2"> break;</span>
<span class="s2"> }</span>
<span class="s2"> Y = (Y - 0.0625) * 1.168949772;</span>
<span class="s2"> Cb = (Cb - 0.0625) * 1.142857143 - 0.5;</span>
<span class="s2"> Cr = (Cr - 0.0625) * 1.142857143 - 0.5;</span>
<span class="s2"> color.r = Y + 1.5748 * Cr;</span>
<span class="s2"> color.g = Y - 0.1873 * Cb - 0.4681 * Cr;</span>
<span class="s2"> color.b = Y + 1.8556 * Cb;</span>
<span class="s2"> color.a = 0.7;</span>
<span class="s2"> gl_FragColor = color;</span>
<span class="s2"> }</span>
<span class="s2">"""</span>
<span class="c1"># The exhausitve list of pixel formats that are transferred as float texture</span>
<span class="c1"># Only use those for greater efficiency and compatibility.</span>
<span class="c1">#</span>
<span class="n">fg_shaders</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">'2vuy'</span> <span class="p">:</span><span class="n">FragmentShader_2vuy</span><span class="p">,</span>
<span class="s1">'8BitYUV'</span> <span class="p">:</span><span class="n">FragmentShader_2vuy</span><span class="p">,</span>
<span class="s1">'v210'</span> <span class="p">:</span><span class="n">FragmentShader_v210</span><span class="p">,</span>
<span class="s1">'10BitYUV'</span> <span class="p">:</span><span class="n">FragmentShader_v210</span><span class="p">,</span>
<span class="s1">'8BitBGRA'</span> <span class="p">:</span><span class="n">FragmentShader_R10l</span><span class="p">,</span>
<span class="s1">'BGRA'</span> <span class="p">:</span><span class="n">FragmentShader_R10l</span><span class="p">,</span>
<span class="s1">'8BitARGB'</span> <span class="p">:</span><span class="n">FragmentShader_R10l</span><span class="p">,</span>
<span class="s1">'10BitRGBXLE'</span><span class="p">:</span><span class="n">FragmentShader_R10l</span><span class="p">,</span>
<span class="s1">'R10l'</span> <span class="p">:</span><span class="n">FragmentShader_R10l</span>
<span class="p">}</span>
<span class="c1">#</span>
<span class="c1"># Helper function to attach a pixel shader to the material that receives the video frame.</span>
<span class="c1">#</span>
<span class="k">def</span> <span class="nf">config_video</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="nb">format</span><span class="p">,</span> <span class="n">pixel</span><span class="p">,</span> <span class="n">is3D</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">mat</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">card</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="k">if</span> <span class="n">pixel</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">fg_shaders</span><span class="p">:</span>
<span class="k">raise</span><span class="p">(</span><span class="s1">'Unsuported shader'</span><span class="p">)</span>
<span class="n">shader</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">meshes</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">materials</span><span class="p">[</span><span class="n">mat</span><span class="p">]</span><span class="o">.</span><span class="n">getShader</span><span class="p">()</span>
<span class="k">if</span> <span class="n">shader</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">shader</span><span class="o">.</span><span class="n">isValid</span><span class="p">():</span>
<span class="n">shader</span><span class="o">.</span><span class="n">setSource</span><span class="p">(</span><span class="n">VertexShader</span><span class="p">,</span> <span class="n">fg_shaders</span><span class="p">[</span><span class="n">pixel</span><span class="p">],</span> <span class="kc">True</span><span class="p">)</span>
<span class="n">shader</span><span class="o">.</span><span class="n">setSampler</span><span class="p">(</span><span class="s1">'tex'</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">shader</span><span class="o">.</span><span class="n">setUniformEyef</span><span class="p">(</span><span class="s2">"eye"</span><span class="p">)</span>
<span class="n">shader</span><span class="o">.</span><span class="n">setUniform1f</span><span class="p">(</span><span class="s2">"stereo"</span><span class="p">,</span> <span class="mf">0.5</span> <span class="k">if</span> <span class="n">is3D</span> <span class="k">else</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">tex</span> <span class="o">=</span> <span class="n">vt</span><span class="o">.</span><span class="n">Texture</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">mat</span><span class="p">)</span>
<span class="n">tex</span><span class="o">.</span><span class="n">source</span> <span class="o">=</span> <span class="n">vt</span><span class="o">.</span><span class="n">VideoDeckLink</span><span class="p">(</span><span class="nb">format</span> <span class="o">+</span> <span class="s2">"/"</span> <span class="o">+</span> <span class="n">pixel</span> <span class="o">+</span> <span class="p">(</span><span class="s2">"/3D"</span> <span class="k">if</span> <span class="n">is3D</span> <span class="k">else</span> <span class="s2">""</span><span class="p">),</span> <span class="n">card</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"frame rate: "</span><span class="p">,</span> <span class="n">tex</span><span class="o">.</span><span class="n">source</span><span class="o">.</span><span class="n">framerate</span><span class="p">)</span>
<span class="n">tex</span><span class="o">.</span><span class="n">source</span><span class="o">.</span><span class="n">play</span><span class="p">()</span>
<span class="n">obj</span><span class="p">[</span><span class="s2">"video"</span><span class="p">]</span> <span class="o">=</span> <span class="n">tex</span>
<span class="c1">#</span>
<span class="c1"># Attach this function to an object that has a material with texture</span>
<span class="c1"># and call it once to initialize the object</span>
<span class="c1">#</span>
<span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="n">cont</span><span class="p">):</span>
<span class="c1"># config_video(cont.owner, 'HD720p5994', '8BitBGRA')</span>
<span class="c1"># config_video(cont.owner, 'HD720p5994', '8BitYUV')</span>
<span class="c1"># config_video(cont.owner, 'pal ', '10BitYUV')</span>
<span class="n">config_video</span><span class="p">(</span><span class="n">cont</span><span class="o">.</span><span class="n">owner</span><span class="p">,</span> <span class="s1">'pal '</span><span class="p">,</span> <span class="s1">'8BitYUV'</span><span class="p">)</span>
<span class="c1">#</span>
<span class="c1"># To be called on every frame</span>
<span class="c1">#</span>
<span class="k">def</span> <span class="nf">play</span><span class="p">(</span><span class="n">cont</span><span class="p">):</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">cont</span><span class="o">.</span><span class="n">owner</span>
<span class="n">video</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"video"</span><span class="p">)</span>
<span class="k">if</span> <span class="n">video</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">video</span><span class="o">.</span><span class="n">refresh</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>
<section id="video-classes">
<h2>Video classes<a class="headerlink" href="#video-classes" title="Link to this heading"></a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">bge.texture.</span></span><span class="sig-name descname"><span class="pre">VideoFFmpeg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">capture</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">25.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">height</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.VideoFFmpeg" title="Link to this definition"></a></dt>
<dd><p>FFmpeg video source, used for video files, video captures, or video streams.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>file</strong> (<em>str</em>) – Path to the video to load; if capture >= 0 on Windows, this parameter will not be used.</p></li>
<li><p><strong>capture</strong> (<em>int</em>) – Capture device number; if >= 0, the corresponding webcam will be used. (optional)</p></li>
<li><p><strong>rate</strong> (<em>float</em>) – Capture rate. (optional, used only if capture >= 0)</p></li>
<li><p><strong>width</strong> (<em>int</em>) – Capture width. (optional, used only if capture >= 0)</p></li>
<li><p><strong>height</strong> (<em>int</em>) – Capture height. (optional, used only if capture >= 0)</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.status">
<span class="sig-name descname"><span class="pre">status</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.status" title="Link to this definition"></a></dt>
<dd><p>Video status. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
<dt class="field-even">Value<span class="colon">:</span></dt>
<dd class="field-even"><p>see <a class="reference internal" href="#ffmpeg-video-and-image-status">FFmpeg Video and Image Status</a>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.range">
<span class="sig-name descname"><span class="pre">range</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.range" title="Link to this definition"></a></dt>
<dd><p>The start and stop time of the video playback, expressed in seconds from beginning.
By default the entire video.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>sequence of two floats</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.repeat">
<span class="sig-name descname"><span class="pre">repeat</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.repeat" title="Link to this definition"></a></dt>
<dd><p>Number of times to replay the video, -1 for infinite repeat.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.framerate">
<span class="sig-name descname"><span class="pre">framerate</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.framerate" title="Link to this definition"></a></dt>
<dd><p>Relative frame rate, <1.0 for slow, >1.0 for fast.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.valid">
<span class="sig-name descname"><span class="pre">valid</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.valid" title="Link to this definition"></a></dt>
<dd><p>Tells if an image is available. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.image">
<span class="sig-name descname"><span class="pre">image</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.image" title="Link to this definition"></a></dt>
<dd><p>Image data. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="bgl.html#bgl.Buffer" title="bgl.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a> or None</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.size">
<span class="sig-name descname"><span class="pre">size</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.size" title="Link to this definition"></a></dt>
<dd><p>Image size. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>tuple of two ints</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.scale">
<span class="sig-name descname"><span class="pre">scale</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.scale" title="Link to this definition"></a></dt>
<dd><p>Set to True to activate fast nearest neighbor scaling algorithm.
Texture width and height must be a power of 2.
If the video picture size is not a power of 2, rescaling is required.
By default <code class="docutils literal notranslate"><span class="pre">bge.texture</span></code> uses the precise but slow <code class="docutils literal notranslate"><span class="pre">gluScaleImage()</span></code> function.
Best is to rescale the video offline so that no scaling is necessary at runtime!</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.flip">
<span class="sig-name descname"><span class="pre">flip</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.flip" title="Link to this definition"></a></dt>
<dd><p>If True the imaged will be flipped vertically.
FFmpeg always delivers the image upside down, so this attribute is set to True by default.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.filter">
<span class="sig-name descname"><span class="pre">filter</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.filter" title="Link to this definition"></a></dt>
<dd><p>An additional filter that is applied on the video before sending it to the GPU.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>one of:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bge.texture.FilterBGR24" title="bge.texture.FilterBGR24"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterBGR24</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterBlueScreen" title="bge.texture.FilterBlueScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterBlueScreen</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterColor" title="bge.texture.FilterColor"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterColor</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterGray" title="bge.texture.FilterGray"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterGray</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterLevel" title="bge.texture.FilterLevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterLevel</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterNormal" title="bge.texture.FilterNormal"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterNormal</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterRGB24" title="bge.texture.FilterRGB24"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterRGB24</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterRGBA32" title="bge.texture.FilterRGBA32"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterRGBA32</span></code></a></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.preseek">
<span class="sig-name descname"><span class="pre">preseek</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.preseek" title="Link to this definition"></a></dt>
<dd><p>Number of frames of preseek.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.deinterlace">
<span class="sig-name descname"><span class="pre">deinterlace</span></span><a class="headerlink" href="#bge.texture.VideoFFmpeg.deinterlace" title="Link to this definition"></a></dt>
<dd><p>Deinterlace image.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.play">
<span class="sig-name descname"><span class="pre">play</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.VideoFFmpeg.play" title="Link to this definition"></a></dt>
<dd><p>Play (restart) video.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>Whether the video was ready or stopped.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.pause">
<span class="sig-name descname"><span class="pre">pause</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.VideoFFmpeg.pause" title="Link to this definition"></a></dt>
<dd><p>Pause video.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>Whether the video was playing.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.stop">
<span class="sig-name descname"><span class="pre">stop</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.VideoFFmpeg.stop" title="Link to this definition"></a></dt>
<dd><p>Stop video (play will replay it from start).</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>Whether the video was playing.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.VideoFFmpeg.refresh">
<span class="sig-name descname"><span class="pre">refresh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">format</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RGBA'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timestamp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1.0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.VideoFFmpeg.refresh" title="Link to this definition"></a></dt>
<dd><p>Refresh video - get its status and optionally copy the frame to an external buffer.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<em>any buffer type</em>) – An optional object that implements the buffer protocol.
If specified, the image is copied to the buffer, which must be big enough or an exception is thrown.</p></li>
<li><p><strong>format</strong> (<em>str</em>) – An optional image format specifier for the image that will be copied to the buffer.
Only valid values are “RGBA” or “BGRA”</p></li>
<li><p><strong>timestamp</strong> (<em>float</em>) – An optional timestamp (in seconds from the start of the movie)
of the frame to be copied to the buffer.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>see <a class="reference internal" href="#ffmpeg-video-and-image-status">FFmpeg Video and Image Status</a>.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</section>
<section id="image-classes">
<h2>Image classes<a class="headerlink" href="#image-classes" title="Link to this heading"></a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">bge.texture.</span></span><span class="sig-name descname"><span class="pre">ImageFFmpeg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.ImageFFmpeg" title="Link to this definition"></a></dt>
<dd><p>FFmpeg image source, used for image files and web based images.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>file</strong> (<em>str</em>) – Path to the image to load.</p>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.status">
<span class="sig-name descname"><span class="pre">status</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.status" title="Link to this definition"></a></dt>
<dd><p>Image status. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
<dt class="field-even">Value<span class="colon">:</span></dt>
<dd class="field-even"><p>see <a class="reference internal" href="#ffmpeg-video-and-image-status">FFmpeg Video and Image Status</a>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.valid">
<span class="sig-name descname"><span class="pre">valid</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.valid" title="Link to this definition"></a></dt>
<dd><p>Tells if an image is available. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.image">
<span class="sig-name descname"><span class="pre">image</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.image" title="Link to this definition"></a></dt>
<dd><p>Image data. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="bgl.html#bgl.Buffer" title="bgl.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a> or None</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.size">
<span class="sig-name descname"><span class="pre">size</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.size" title="Link to this definition"></a></dt>
<dd><p>Image size. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>tuple of two ints</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.scale">
<span class="sig-name descname"><span class="pre">scale</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.scale" title="Link to this definition"></a></dt>
<dd><p>Fast scale of image (near neighbour).</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.flip">
<span class="sig-name descname"><span class="pre">flip</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.flip" title="Link to this definition"></a></dt>
<dd><p>Flip image vertically.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.filter">
<span class="sig-name descname"><span class="pre">filter</span></span><a class="headerlink" href="#bge.texture.ImageFFmpeg.filter" title="Link to this definition"></a></dt>
<dd><p>Pixel filter.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>one of…</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bge.texture.FilterBGR24" title="bge.texture.FilterBGR24"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterBGR24</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterBlueScreen" title="bge.texture.FilterBlueScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterBlueScreen</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterColor" title="bge.texture.FilterColor"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterColor</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterGray" title="bge.texture.FilterGray"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterGray</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterLevel" title="bge.texture.FilterLevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterLevel</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterNormal" title="bge.texture.FilterNormal"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterNormal</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterRGB24" title="bge.texture.FilterRGB24"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterRGB24</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterRGBA32" title="bge.texture.FilterRGBA32"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterRGBA32</span></code></a></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.refresh">
<span class="sig-name descname"><span class="pre">refresh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">buffer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">format</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RGBA'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.ImageFFmpeg.refresh" title="Link to this definition"></a></dt>
<dd><p>Refresh image, get its status and optionally copy the frame to an external buffer.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>buffer</strong> (<em>any buffer type</em>) – An optional object that implements the buffer protocol.
If specified, the image is copied to the buffer, which must be big enough or an exception is thrown.</p></li>
<li><p><strong>format</strong> (<em>str</em>) – An optional image format specifier for the image that will be copied to the buffer.
Only valid values are “RGBA” or “BGRA”</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>see <a class="reference internal" href="#ffmpeg-video-and-image-status">FFmpeg Video and Image Status</a>.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.ImageFFmpeg.reload">
<span class="sig-name descname"><span class="pre">reload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newname</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.ImageFFmpeg.reload" title="Link to this definition"></a></dt>
<dd><p>Reload image, i.e. reopen it.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>newname</strong> (<em>str</em>) – Path to a new image. (optional)</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="bge.texture.ImageBuff">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">bge.texture.</span></span><span class="sig-name descname"><span class="pre">ImageBuff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">height</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.ImageBuff" title="Link to this definition"></a></dt>
<dd><p>Image from application memory.
For computer generated images, drawing applications.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>width</strong> (<em>int</em>) – Width of the image.</p></li>
<li><p><strong>height</strong> (<em>int</em>) – Height of the image.</p></li>
<li><p><strong>color</strong> (<em>int in</em><em> [</em><em>0</em><em>, </em><em>255</em><em>]</em>) – Value to initialize RGB channels with. The initialized buffer will have
all pixels set to (color, color, color, 255). (optional)</p></li>
<li><p><strong>scale</strong> (<em>bool</em>) – Image uses scaling. (optional)</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.filter">
<span class="sig-name descname"><span class="pre">filter</span></span><a class="headerlink" href="#bge.texture.ImageBuff.filter" title="Link to this definition"></a></dt>
<dd><p>Pixel filter.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>one of…</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bge.texture.FilterBGR24" title="bge.texture.FilterBGR24"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterBGR24</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterBlueScreen" title="bge.texture.FilterBlueScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterBlueScreen</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterColor" title="bge.texture.FilterColor"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterColor</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterGray" title="bge.texture.FilterGray"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterGray</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterLevel" title="bge.texture.FilterLevel"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterLevel</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterNormal" title="bge.texture.FilterNormal"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterNormal</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterRGB24" title="bge.texture.FilterRGB24"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterRGB24</span></code></a></p></li>
<li><p><a class="reference internal" href="#bge.texture.FilterRGBA32" title="bge.texture.FilterRGBA32"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilterRGBA32</span></code></a></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.flip">
<span class="sig-name descname"><span class="pre">flip</span></span><a class="headerlink" href="#bge.texture.ImageBuff.flip" title="Link to this definition"></a></dt>
<dd><p>Flip image vertically.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.image">
<span class="sig-name descname"><span class="pre">image</span></span><a class="headerlink" href="#bge.texture.ImageBuff.image" title="Link to this definition"></a></dt>
<dd><p>Image data. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="bgl.html#bgl.Buffer" title="bgl.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a> or None</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.load">
<span class="sig-name descname"><span class="pre">load</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">imageBuffer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">height</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.ImageBuff.load" title="Link to this definition"></a></dt>
<dd><p>Load image from buffer.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>imageBuffer</strong> (<a class="reference internal" href="bgl.html#bgl.Buffer" title="bgl.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a> or Python object implementing the buffer protocol (f.ex. bytes)) – Buffer to load the image from.</p></li>
<li><p><strong>width</strong> (<em>int</em>) – Width of the image to load.</p></li>
<li><p><strong>height</strong> (<em>int</em>) – Height of the image to load.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.plot">
<span class="sig-name descname"><span class="pre">plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">imageBuffer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">height</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">positionX</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">positionY</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">IMB_BLEND_COPY</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#bge.texture.ImageBuff.plot" title="Link to this definition"></a></dt>
<dd><p>Update image buffer.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>imageBuffer</strong> (<a class="reference internal" href="bgl.html#bgl.Buffer" title="bgl.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a>, <a class="reference internal" href="#bge.texture.ImageBuff" title="bge.texture.ImageBuff"><code class="xref py py-class docutils literal notranslate"><span class="pre">ImageBuff</span></code></a>
or Python object implementing the buffer protocol (f.ex. bytes)) – Buffer to load the new data from.</p></li>
<li><p><strong>width</strong> (<em>int</em>) – Width of the data to load.</p></li>
<li><p><strong>height</strong> (<em>int</em>) – Height of the data to load.</p></li>
<li><p><strong>positionX</strong> (<em>int</em>) – Left boundary of the region to be drawn on.</p></li>
<li><p><strong>positionY</strong> (<em>int</em>) – Upper boundary of the region to be drawn on.</p></li>
<li><p><strong>mode</strong> (<em>int</em>) – Drawing mode, see <a class="reference internal" href="#image-blending-modes">Image Blending Modes</a>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.scale">
<span class="sig-name descname"><span class="pre">scale</span></span><a class="headerlink" href="#bge.texture.ImageBuff.scale" title="Link to this definition"></a></dt>
<dd><p>Fast scale of image (near neighbour).</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.size">
<span class="sig-name descname"><span class="pre">size</span></span><a class="headerlink" href="#bge.texture.ImageBuff.size" title="Link to this definition"></a></dt>
<dd><p>Image size. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>tuple of two ints</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="bge.texture.ImageBuff.valid">
<span class="sig-name descname"><span class="pre">valid</span></span><a class="headerlink" href="#bge.texture.ImageBuff.valid" title="Link to this definition"></a></dt>
<dd><p>Tells if an image is available. (readonly)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="bge.texture.ImageMirror">