Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has setting about crop background #1180

Closed
lssler opened this issue Nov 4, 2022 · 15 comments
Closed

has setting about crop background #1180

lssler opened this issue Nov 4, 2022 · 15 comments

Comments

@lssler
Copy link

lssler commented Nov 4, 2022

mintty auto crop image to fit background
in wintext.c static void load_background_image_brush(HDC dc, wstring fn)
change:
HDC dc0 = CreateCompatibleDC(dc);
HBITMAP oldhbm0 = SelectObject(dc0, hbm);

  // prepare destination memory DC, 
  // create and select the destination bitmap into it

  ///////////////////////////////////////////
  //crop image
  int imgw = w;
  int imgh = h;
  if(bw*h > w*bh)
  {
    imgw = w;
    imgh = bh*imgw/bw;
  }
  else if (bw*h < w*bh)
  {
    imgh = h;
    imgw = bw*imgh/bh;

  }
  w = imgw;
  h = imgh;
@mintty
Copy link
Owner

mintty commented Nov 4, 2022

I am missing an explanation what this piece of code is meant to suggest or achieve...

@lssler lssler closed this as completed Nov 5, 2022
@lssler lssler reopened this Nov 5, 2022
@lssler
Copy link
Author

lssler commented Nov 5, 2022

I am missing an explanation what this piece of code is meant to suggest or achieve...

it crop the picture to avoid deformation when window size changes, instead of scale image to fit window

@mintty
Copy link
Owner

mintty commented Nov 5, 2022

I could try, but... could you clarify which of the background image modes is supposed to be affected?
How do you invoke mintty to get something that your patch changes?
Also, as I thought to have implemented all variations in the best way, what do you think is wrong about current behaviour?

@lssler
Copy link
Author

lssler commented Nov 5, 2022

background " _" is changed, it just change "scaled" to "crop".now ,i set background with " _", then window ratio is different from img ratio ,so, the img is scaled to window ratio. The code scale img with img's original ratio.It looks better when change window size

@mintty
Copy link
Owner

mintty commented Nov 5, 2022

How do you invoke mintty to get something that your patch changes?

Please quote your command. Note there is a variation of behaviour already available, maybe prefix % to the image filename is what you want?
Otherwise, if you really mean to crop the image when resizing the terminal, it would not fill the complete background but would leave some empty area, which I do not consider desirable. On the other hand, there is also a tiling prefix *.

@lssler lssler closed this as completed Nov 5, 2022
@lssler lssler reopened this Nov 5, 2022
@lssler
Copy link
Author

lssler commented Nov 5, 2022

it will not has empty area,it will sacle until fill all area.

@lssler
Copy link
Author

lssler commented Nov 5, 2022

无标题

@mintty
Copy link
Owner

mintty commented Nov 5, 2022

I don't like guesswork investigation so much. You have still not answered my question how you invoke mintty to demonstrate the difference (i.e. which mode of Background=... you use). Also there are two similar locations in the source file where your patch would fit.

@mintty
Copy link
Owner

mintty commented Nov 5, 2022

OK, if I guess right (:/) instead of simple tiling, you want to scale first, keeping aspect ratio, then tile.
This is not suitable for images (see below) but may be OK for patterns intended for tiling.
It would not be a change, however (see example) but rather a new mode.
grafik

@mintty
Copy link
Owner

mintty commented Nov 5, 2022

Prefix syntax could be _* (as these two functions are combined), +, , or :.

@lssler
Copy link
Author

lssler commented Nov 5, 2022

The code used in function "static void load_background_image_brush(HDC dc, wstring fn)",in 1813 line

It is right scale first, keeping aspect ratio, then tile
The original tile is use pic size

@lssler lssler closed this as completed Nov 5, 2022
@lssler lssler reopened this Nov 5, 2022
@lssler
Copy link
Author

lssler commented Nov 5, 2022

If image is bigger then mintty size or more small ,the code can automatically scale img to suitable size.

@mintty
Copy link
Owner

mintty commented Nov 5, 2022

It is right scale first

or bottom scale first, depending on the dimensions.
This proposal needs some time to settle; it needs another flag and integration into the option.

@mintty
Copy link
Owner

mintty commented Nov 12, 2022

I introduced this now with background image prefix + in either option Background or OSC 11.

@mintty
Copy link
Owner

mintty commented Nov 14, 2022

Released 3.6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants