missionpinball/mpf-mc

color-DMD effect size, image and font scaling issue

borgdog opened this issue · 0 comments

I'm setting up a lcd screen to have the DMD look at 192x64 size, following the instructions on this page https://missionpinball.org/mc/displays/adding_dot_look_to_lcd/

I was having trouble, so reduced my code down to just what that page shows but at the resolutions I want (plus stuff to actually run). It seems the part where it says "We do not set the number of dots in the DMD here, as that's automatically pulled in from the dmd display setting." is not working. If I don't define the number of dots then it does 128 wide and whatever tall fits in the window. Adding in dots_x and dots_y in the color_dmd slide with the appropriate values and everything works.

So, bug in the code maybe? something changed where it doesn't work anymore?

my test config.yaml below, using latest dev (mpf 0.57.0.dev32, mpf-mc 0.57.0dev12). note this does have the dots_x and dots_y in it so sizes correctly, just comment those out to see what it does incorrectly.

#config_version=6
# DMDTEST 


mpf:
  report_crashes: never

hardware:
  platform: smart_virtual

window:
  width: 1920
  height: 640
  resizable: false
  fullscreen: false
  borderless: true
  exit_on_escape: true

displays:
  window:
    width: 1920
    height: 640
  dmd:
    width: 192
    height: 64
    round_anchor_x: left
    round_anchor_y: bottom
    default: true

slides:
  window_slide:
    - type: display
      effects:
        - type: color_dmd
          dot_filter: true
          dot_size: .65
          dots_x: 192
          dots_y: 64
          blur: 0
      width: 1920
      height: 640

  dmd_slide:

    - type: text
      text: DOTS!
    - type: rectangle
      width: 192
      height: 64
      color: orange
      y: 0
      anchor_y: bottom
    - type: rectangle
      width: 192
      height: 64
      color: red
      y: top
      anchor_y: top

slide_player:
  init_done:
    window_slide:
      target: window
    dmd_slide:
      target: dmd

the next part of the issue is scaling. it is interpolating incorrectly when scaling up to fit the window size based on a DMD size image, in my case a 192x64 image, getting scaled to 1920x640 gives this:

image

instead of the correctly 'nearest' scaling method that gives this:

image

I did find that if I add self.texture.mag_filter = 'nearest' to the def _on_texture_change section of image.py it does give me the desired effect for images.

But ideally it would be something we could set in our config files, but that is way beyond me. it also needs to take effect for text as well as images. I have looked briefly in text.py but have not figured out a solution for that one yet. here is the widget with scaled text that shows the blurring of the pixel font that results from the default (linear) scaling interpolation.

image

Here is the beginning part of the def _on_texture_change section of image.py to show where I put it.


    def _on_texture_change(self, *args) -> None:
        """Update texture from image asset (callback when image texture changes)."""
        del args


        self.texture = self._image.image.texture
        self.texture.mag_filter = 'nearest'
        self.size = self.texture.size
        self._draw_widget()`

Maybe there is already a way to add the texture.mag_filter in the yaml files, but I'm not finding it.