Forum Rule: Always post complete source code & details to reproduce any issue!
Page 3 of 3 FirstFirst 1 2 3
Results 51 to 52 of 52

Thread: tgx: a 2D/3D graphics library for Teensy.

  1. #51
    Senior Member
    Join Date
    Jan 2014
    Posts
    103
    Another request/question. Would it be possible to have different x and y scaling on scalable blits, or if thats too slow or complicated, perhaps just scale in only 1 dimension?

  2. #52
    Quote Originally Posted by neutron7 View Post
    Another request/question. Would it be possible to have different x and y scaling on scalable blits, or if thats too slow or complicated, perhaps just scale in only 1 dimension?
    Hi,

    Yes, it is already possible using the copyFrom() method which blits a source image over a destination image whatever there sizes may be (scaling is done using bilinear filtering). So for example, the code below
    Code:
    im2.getCrop(B2).copyfrom(im1.getCrop(B1))
    blits the region of im1 delimited by B1 onto the region of im2 delimited by B2 and these 2 iBox2 B1 and B2 need not have the same size or same aspect ratio.

    The getCrop() notation is a bit heavy so I have now added a alias with operator() so that im(B) is the same as im.getCrop(B). Thus, you could simply write:
    Code:
    im2(B2).copyfrom(im1(B1))
    which is, I think, more readable. However, in order to use operator(), you will need to switch to the improved-drawing-primitives branch on github or wait for the branch merging in a few days...

    Also, there are even more powerful methods available such as drawTextureQuad() which can not only blit between rectangular regions but even between quadrilateral regions (not necessarily rectangles) and still with bilinear filtering . And then, there are also methods for doing quadrilateral mapping with gradient, with masking... I will try to make a wiki on github to list the available methods when I am done with the library new drawing primitives.
    Last edited by vindar; 09-27-2022 at 06:56 AM. Reason: typo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •