Resizing an image to fullscreen (à la Windows Desktop)

Just starting out? Need help? Post your questions and find answers here.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by RASHAD »

Yeee
You are QHD idle
Blue win :mrgreen:
Egypt my love
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by idle »

I would have said blue wins QED
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by RASHAD »

I see
You are trying to insult my monitor idle :evil:
Egypt my love
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by idle »

RASHAD wrote: Fri Mar 31, 2023 8:28 pm I see
You are trying to insult my monitor idle :evil:
no not all, but if you run some of my code it will! :lol:
ZX80
Enthusiast
Enthusiast
Posts: 330
Joined: Mon Dec 12, 2016 1:37 pm

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by ZX80 »

Hello, RASHAD.

How to maintain the aspect ratio of an image when resizing the window ?
So that the original image is not stretched or distorted, and unoccupied areas are filled with a black background. Let's assume that you only resized the window in the x or y coordinate, then you only need to add stripes on the sides or top and on the bottom.
Hope I was able to explain. It's like watching a widescreen movie on a 4:3 aspect ratio display. That is, I need to enlarge or reduce the image proportionally.
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by Blue »

idle wrote: Fri Mar 31, 2023 7:50 pm I think it's time for some wrapper macros to handle this dpi stuff, we shouldn't need to do anything apart from setting a flag.
Totally agreed.
Even though it must be said that things have steadily improved over the last 2 years with respect to this issue.

Screen resolution on my 16" display :
Yes, a very high — and pleasant — resolution. Surprisingly, no problems with it... except in the PB editor; its text cursor is a very thin 1-pixel line that is almost invisible most of the time. I haven't found a way to make it wider, so i end up wasting quite a bit of time figuring out where that cursor has disappeared again !
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by RASHAD »

Hi ZX80
It looks to me that we are hijacking Blue post now :D
Next snippet with Aspect Ratio

Code: Select all

Global dpix.d,dpiy.d,asp.d,w.d
dpix = DesktopResolutionX()
dpiy = DesktopResolutionY()

UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()

ExamineDesktops()

Procedure sizeCB()
  If IsImage(0)
    CopyImage(0,1)
    If asp >= 1
      w = WindowWidth(0)*dpiy
    Else
      w = WindowHeight(0)*dpiy*asp
    EndIf  
    ResizeGadget(0,0,0,WindowWidth(0)*dpix,WindowHeight(0)*dpiy)
    ResizeGadget(10,0,0,WindowWidth(0),WindowHeight(0))
    ResizeImage(1,w,w/asp)
    SetGadgetAttribute(10,#PB_Button_Image,ImageID(1))
  EndIf
EndProcedure

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Right Mouse for Context Menu",Flags)

If CreatePopupImageMenu(0)
  MenuItem(1, "Open",LoadImage(10, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  MenuItem(2, "Copy",LoadImage(20, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Copy.png"))
  MenuItem(3, "Paste",LoadImage(30, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Paste.png"))
  MenuBar()
    MenuItem(4, "Save As..",LoadImage(40, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
  MenuBar()
  OpenSubMenu("Resize Image")
    MenuItem(5, "Full Screen",LoadImage(50, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
    MenuItem(6, "Normal Screen",LoadImage(60, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  CloseSubMenu()
  MenuBar()
  MenuItem( 7, "Quit",LoadImage(70, #PB_Compiler_Home + "examples/sources/Data/ToolBar/New.png"))
EndIf

ContainerGadget(0,0,0,WindowWidth(0),WindowHeight(0))
  ButtonImageGadget(10,0,0,WindowWidth(0),WindowHeight(0),0)
CloseGadgetList()
DisableGadget(0,1) 
BindEvent(#PB_Event_SizeWindow,@sizeCB())
Repeat
           
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1
      
      Case #PB_Event_Timer
      
      Case #PB_Event_RightClick
        DisplayPopupMenu(0, WindowID(0),DesktopMouseX(),DesktopMouseY())
      
      Case #PB_Event_Menu
        Select EventMenu()
          Case 1
            Filename$ = OpenFileRequester("Image", "", "Image|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.tiff", 0)
            If FileSize(Filename$) >= 0
              result = LoadImage(0,Filename$)
              If result
                CopyImage(0,1)
                asp = ImageWidth(0)/ImageHeight(0)
                If asp >= 1
                  w = WindowWidth(0)*dpiy
                Else
                  w = WindowHeight(0)*dpiy*asp
                EndIf              
                ResizeImage(1,w,w/asp)
                SetGadgetAttribute(10, #PB_Button_Image,ImageID(1))
              EndIf
            Else
              MessageRequester("Error","No image loaded",#MB_OK)
            EndIf
          
          Case 2
            If IsImage(1)
              SetClipboardImage(1)
            EndIf
                        
          Case 3
            If GetClipboardImage(0)
              CopyImage(0,1)
              ResizeImage(1,w,w/asp)
              SetGadgetAttribute(10, #PB_Button_Image,ImageID(1))
            EndIf
            
          Case 4
            If IsImage(1)
              imgH = GetGadgetAttribute(10,#PB_Button_Image)
              CreateImage(10,ImageWidth(1),ImageHeight(1),24)
              StartDrawing(ImageOutput(10))
                DrawImage(imgH,0,0)
              StopDrawing()
              SaveImage(10,GetTemporaryDirectory()+"Test.bmp")
              FreeImage(10)
            EndIf
            
          Case 5
            nx = WindowX(0)
            ny = WindowY(0)
            nw = WindowWidth(0)
            nh = WindowHeight(0)
            SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)&~ #WS_THICKFRAME &~ #WS_DLGFRAME)
            ResizeWindow(0,0,0,DesktopWidth(0),DesktopHeight(0))
          
          Case 6
            SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)|#WS_THICKFRAME | #WS_DLGFRAME)
            ResizeWindow(0,nx,ny,nw,nh)
          
          Case 7
            End                     
        EndSelect
      
      Case #PB_Event_Gadget
          Select EventGadget()
           Case 1            
          EndSelect          

  EndSelect 

Until Quit = 1
End

Edit : Bug fixed
Last edited by RASHAD on Sat Apr 01, 2023 5:01 pm, edited 1 time in total.
Egypt my love
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by Blue »

RASHAD wrote: Sat Apr 01, 2023 8:07 am Hi ZX80
It looks to me that we are hijacking Blue post now :D
No, no Rashad. No hijacking charge will be levied here. :D
ZX80’s preoccupation goes right to the heart of the subject. So does the code you keep contributing. So, overall, medals of achievement to everyone. 8)

.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
ZX80
Enthusiast
Enthusiast
Posts: 330
Joined: Mon Dec 12, 2016 1:37 pm

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by ZX80 »

RASHAD, thank you very much for your work. Yes, it works great now :!:
Now we have another very useful code. Thanks again for sharing this with us.
RASHAD wrote: Sat Apr 01, 2023 8:07 am Hi ZX80
It looks to me that we are hijacking Blue post now :D
Next snippet with Aspect Ratio
I think that he will be happy about it :mrgreen:

Blue, thanks, I just liked RASHAD's code. And while he did not go far from this topic, I wanted his solution to be more complete.
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by Caronte3D »

idle wrote: Fri Mar 31, 2023 7:50 pm I think it's time for some wrapper macros to handle this dpi stuff, we shouldn't need to do anything apart from setting a flag.
+1000
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by RASHAD »

Hi Blue
Hi ZX80
Well next is another view using CanvasGadget() to add MouseWheel to the controls

Code: Select all

Global dpix.d,dpiy.d,asp.d,w.d,scale.f
dpix = DesktopResolutionX()
dpiy = DesktopResolutionY()

UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()

ExamineDesktops()

Procedure sizeCB()
  If IsImage(0)
    CopyImage(0,1)
    If asp >= 1
      w = WindowWidth(0)*dpiy
    Else
      w = WindowHeight(0)*dpiy*asp
    EndIf
    ResizeImage(1,w,w/asp)
    ResizeGadget(0,0,0,WindowWidth(0)*dpix,WindowHeight(0)*dpiy)
    StartDrawing(CanvasOutput(0))
    Box(0,0,WindowWidth(0),WindowHeight(0),$FFFFFF)
    DrawImage(ImageID(1),(GadgetWidth(0)-ImageWidth(1))/2,(GadgetHeight(0)-ImageHeight(1))/2,ImageWidth(1),ImageHeight(1))
    StopDrawing()
    scale = 1
  EndIf
EndProcedure

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Right Mouse for Context Menu",Flags)

If CreatePopupImageMenu(0)
  MenuItem(1, "Open",LoadImage(10, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  MenuItem(2, "Copy",LoadImage(20, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Copy.png"))
  MenuItem(3, "Paste",LoadImage(30, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Paste.png"))
  MenuBar()
  MenuItem(4, "Save As..",LoadImage(40, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
  MenuBar()
  OpenSubMenu("Resize Image")
  MenuItem(5, "Full Screen",LoadImage(50, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  MenuItem(6, "Normal Screen",LoadImage(60, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  CloseSubMenu()
  MenuBar()
  MenuItem( 7, "Quit",LoadImage(70, #PB_Compiler_Home + "examples/sources/Data/ToolBar/New.png"))
EndIf

CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0))

BindEvent(#PB_Event_SizeWindow,@sizeCB())

scale.f = 1
Repeat           
  Select WaitWindowEvent()      
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Menu
      Select EventMenu()
        Case 1
          Filename$ = OpenFileRequester("Image", "", "Image|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.tiff", 0)
          If FileSize(Filename$) >= 0
            result = LoadImage(0,Filename$)
            If result
              CopyImage(0,1)
              asp = ImageWidth(0)/ImageHeight(0)
              If asp >= 1
                w = WindowWidth(0)*dpiy
              Else
                w = WindowHeight(0)*dpiy*asp
              EndIf              
              ResizeImage(1,w,w/asp)  
              ResizeGadget(0,0,0,WindowWidth(0)*dpix,WindowHeight(0)*dpiy)
              StartDrawing(CanvasOutput(0))
              Box(0,0,WindowWidth(0),WindowHeight(0),$FFFFFF)
              DrawImage(ImageID(1),(GadgetWidth(0)-ImageWidth(1))/2,(GadgetHeight(0)-ImageHeight(1))/2,ImageWidth(1),ImageHeight(1))
              StopDrawing()          
            EndIf
          Else
            MessageRequester("Error","No image loaded",#MB_OK)
          EndIf
          
        Case 2
          If IsImage(1)
            SetClipboardImage(1)
          EndIf
          
        Case 3
          If GetClipboardImage(0)
            CopyImage(0,1)
            ResizeImage(1,w,w/asp)
            StartDrawing(CanvasOutput(0))
            Box(0,0,WindowWidth(0),WindowHeight(0),$FFFFFF)
            DrawImage(ImageID(1),(GadgetWidth(0)-ImageWidth(1))/2,(GadgetHeight(0)-ImageHeight(1))/2,ImageWidth(1),ImageHeight(1))
            StopDrawing()
          EndIf
          
        Case 4
          If IsImage(1)
            StartDrawing(CanvasOutput(0))
            GrabDrawingImage(0,(GadgetWidth(0)-ImageWidth(1))/2,(GadgetHeight(0)-ImageHeight(1))/2,ImageWidth(1),ImageHeight(1))
            StopDrawing()
            SaveImage(0,GetTemporaryDirectory()+"Test.bmp")
            FreeImage(0)
          EndIf
          
        Case 5
          nx = WindowX(0)
          ny = WindowY(0)
          nw = WindowWidth(0)
          nh = WindowHeight(0)
          SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)&~ #WS_THICKFRAME &~ #WS_DLGFRAME)
          ResizeWindow(0,0,0,DesktopWidth(0),DesktopHeight(0))
          
        Case 6
          SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)|#WS_THICKFRAME | #WS_DLGFRAME)
          ResizeWindow(0,nx,ny,nw,nh)
          
        Case 7
          End                     
      EndSelect
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0            
          Select EventType()
            Case #PB_EventType_RightButtonDown
              DisplayPopupMenu(0, WindowID(0),DesktopMouseX(),DesktopMouseY())
              
            Case #PB_EventType_MouseWheel
              If IsImage(0)                  
                Value.f = GetGadgetAttribute(0,#PB_Canvas_WheelDelta )/10
                Scale = scale + value
                If scale > 3
                  scale = 3
                EndIf
                If scale < 0.2
                  scale = 0.2
                EndIf                 
                CopyImage(0,1)
                ResizeImage(1,w,w/asp)
                ResizeWindow(0,#PB_Ignore,#PB_Ignore,WindowWidth(0)*scale,WindowHeight(0)*scale) 
                ResizeGadget(0,0,0,WindowWidth(0),WindowHeight(0))
                StartDrawing(CanvasOutput(0))
                Box(0,0,WindowWidth(0),WindowHeight(0),$FFFFFF)
                DrawImage(ImageID(1),(WindowWidth(0)*dpix-ImageWidth(1))/2,(WindowHeight(0)*dpiy-ImageHeight(1))/2,ImageWidth(1),ImageHeight(1))
                StopDrawing()  
              EndIf
          EndSelect                        
      EndSelect
  EndSelect 
  
Until Quit = 1
End


Egypt my love
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by Blue »

RASHAD wrote: Sat Apr 01, 2023 8:07 am Hi ZX80
It looks to me that we are hijacking Blue post now :D
Next snippet with Aspect Ratio

Code: Select all

[...]
ContainerGadget(0,0,0,WindowWidth(0),WindowHeight(0))
  ButtonImageGadget(10,0,0,WindowWidth(0),WindowHeight(0),0)
CloseGadgetList()
[...]
You're full of surprises — and good ideas ! — Rashad
Using a ButtonImageGadget() to display the image ? Who would have thought ! But it certainly simplifies the process of scaling the picture to the correct aspect and keeping it centered in its window. I'm still struggling to figure out how to achieve the same results with an imageGadget(). I thought that would be simple. But apparently it's not. At least, for me.

Also, just out of curiosity, I tried using the ButtonImageGadget() by itself, without including in a ContainerGadget() and worked just as well, but no colors ! Everything ended up in shades of grey, That was totally unexpected, believe me. I don't know whether it's a bug or a feature, either of Windows 11 or of PB 6.01, but it is definitely a major surprise.

All that to say "Good creative work, Rashad".
Much appreciated.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by RASHAD »

Hi Blue
The DPI scaling is more complicated than you think :)
There are two cases
1- Run the DPI scaling before your application
2- Run the application before the DPI scaling
The more professional case is the application which can take care of the 2 cases [Dynamic & Static objects(ex Images) & Text business]
Next is a model using ImageGadget()

Code: Select all

Global dpix.d,dpiy.d,asp.d,w.d
dpix = DesktopResolutionX()
dpiy = DesktopResolutionY()

UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()

ExamineDesktops()

Procedure sizeCB()
  If IsImage(0)
    CopyImage(0,1)
    If asp >= 1
      w = WindowWidth(0)*dpiy
    Else
      w = WindowHeight(0)*dpiy*asp
    EndIf
    ResizeImage(1,w,w/asp)  
    ResizeGadget(0,0,0,WindowWidth(0)*dpix,WindowHeight(0)*dpiy)
    ResizeGadget(10,(GadgetWidth(0)-ImageWidth(1))/dpix/2,(GadgetHeight(0)-ImageHeight(1))/dpiy/2,ImageWidth(1),ImageHeight(1))
    SetGadgetState(10,ImageID(1)) 
  EndIf
EndProcedure

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Right Mouse for Context Menu",Flags)
;WindowBounds(0,200,150,1920,1080)
If CreatePopupImageMenu(0)
  MenuItem(1, "Open",LoadImage(10, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  MenuItem(2, "Copy",LoadImage(20, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Copy.png"))
  MenuItem(3, "Paste",LoadImage(30, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Paste.png"))
  MenuBar()
  MenuItem(4, "Save As..",LoadImage(40, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
  MenuBar()
  OpenSubMenu("Resize Image")
  MenuItem(5, "Full Screen",LoadImage(50, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  MenuItem(6, "Normal Screen",LoadImage(60, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  CloseSubMenu()
  MenuBar()
  MenuItem( 7, "Quit",LoadImage(70, #PB_Compiler_Home + "examples/sources/Data/ToolBar/New.png"))
EndIf

ContainerGadget(0,0,0,WindowWidth(0),WindowHeight(0))
  SetGadgetColor(0,#PB_Gadget_BackColor,0)
  ImageGadget(10,0,0,0,0,0)
CloseGadgetList()
DisableGadget(0,1)

BindEvent(#PB_Event_SizeWindow,@sizeCB())
Repeat           
  Select WaitWindowEvent()      
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_RightClick
      DisplayPopupMenu(0, WindowID(0),DesktopMouseX(),DesktopMouseY())
      
    Case #PB_Event_Menu
      Select EventMenu()
        Case 1
          Filename$ = OpenFileRequester("Image", "", "Image|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.tiff", 0)
          If FileSize(Filename$) >= 0
            result = LoadImage(0,Filename$)
            If result
              CopyImage(0,1)
              asp = ImageWidth(0)/ImageHeight(0)
              If asp >= 1
                w = WindowWidth(0)*dpiy
              Else
                w = WindowHeight(0)*dpiy*asp
              EndIf              
              ResizeImage(1,w,w/asp)  
              ResizeGadget(0,0,0,WindowWidth(0)*dpix,WindowHeight(0)*dpiy)
              ResizeGadget(10,(GadgetWidth(0)-ImageWidth(1))/dpix/2,(GadgetHeight(0)-ImageHeight(1))/dpiy/2,ImageWidth(1),ImageHeight(1))
              SetGadgetState(10,ImageID(1))         
            EndIf
          Else
            MessageRequester("Error","No image loaded",#MB_OK)
          EndIf
          
        Case 2
          If IsImage(1)
            SetClipboardImage(1)
          EndIf
          
        Case 3
          If GetClipboardImage(0)
            CopyImage(0,1)
            ResizeImage(1,w,w/asp)
            SetGadgetState(10,ImageID(1))
          EndIf
          
        Case 4
          If IsImage(1)
            SaveImage(1,GetTemporaryDirectory()+"Test.bmp")
            FreeImage(1)
          EndIf
          
        Case 5
          nx = WindowX(0)
          ny = WindowY(0)
          nw = WindowWidth(0)
          nh = WindowHeight(0)
          SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)&~ #WS_THICKFRAME &~ #WS_DLGFRAME)
          ResizeWindow(0,0,0,DesktopWidth(0),DesktopHeight(0))
          
        Case 6
          SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE)|#WS_THICKFRAME | #WS_DLGFRAME)
          ResizeWindow(0,nx,ny,nw,nh)
          
        Case 7
          End                     
      EndSelect      

  EndSelect 
  
Until Quit = 1
End
Egypt my love
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by Blue »

RASHAD wrote: Sun Apr 02, 2023 4:09 pm Hi Blue
The DPI scaling is more complicated than you think :)
[…]

Code: Select all

[…]

Procedure sizeCB()
  […]
    ResizeImage(1,w,w/asp)  <<<— this is what I was not doing right ! 
  […]
EndProcedure
No, Rashad : I’m fully aware of how tricky DPi conformity can get. However, I’ve had it tamed and well under control for quite a while now. My problem is not there: where I keep tripping over the flowers in the carpet is in image manipulation. That’s why this ongoing exercise is important and interesting for me.
Coincidentally, just as I was receiving notification of your latest contribution, I was —finally ! — putting my finger on what I was doing incorrectly. The code you just submitted confirmed that and squared me in the right direction. Your efforts and interest in this matter have helped tremendously. They’ve rekindled my interest in PB. So maybe I won’t sleep so much anymore…
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Resizing an image to fullscreen (à la Windows Desktop)

Post by RASHAD »

Hi Blue
When I said that the DPI scaling is very complicated I meant it is complicated for you for me for everyone even Microsoft employees
I keep digging and they keep changing
It's a circle with no end :D
Keep the high spirit
Egypt my love
Post Reply