Thread: Avisynth+
View Single Post
Old 14th January 2020, 15:59   #5073  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by stax76 View Post
https://en.wikipedia.org/wiki/BMP_fi...#Pixel_storage

I tried negative height in source and target rect and everywhere else where a height is defined and it's not working. On StackOverflow it's unanswered:

https://stackoverflow.com/questions/...textdrawbitmap
BITMAPINFOHEADER and friends are old GDI stuff. D2D exclusively uses unsigned coordinates growing left to right, top to bottom. You're not supposed to use clever tricks like negative pitch or height anymore, presumably because these coordinates are getting increasingly abstract and they don't want you to think in terms of pointers and offsets anymore, even though it happens to make sense in the context of plain old RGB bitmaps. You don't really just push raw memory areas to the screen anymore anyway at this high of an API level - D2D supports UI scaling, for example.

Instead the intended way of doing it is manipulating how the input coordinates are mapped to the output coordinates by setting a transformation matrix on the render target using ID2D1RenderTarget::SetTransform().

D2D doesn't come with a vertical mirroring matrix convenience method (rotation around a point isn't the same thing), but you can just create your own 3x2 transform, like so:

Code:
1    0
0   -1
0    0
which should give you a vertical flip.

Quote:
Originally Posted by stax76 View Post
no clue why AviSynth/VapourSynth RGB32 isn't directly D2D compatible without FlipVertical.
Avisynth predates D2D by over a decade, so that's sort of a silly question. Avisynth directly supports VfW and GDI, which is what was available at the time. VS on the other hand only supports packed RGB32 as a backwards compatibility thing, where the thing it's backwards compatible with is mostly Avisynth.

Last edited by TheFluff; 14th January 2020 at 16:22.
TheFluff is offline