Thread: Scaling window to height of screen....

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2020
    Posts
    3

    Question Scaling window to height of screen....

    HI..

    I am currently learning to code in C & have managed to code a super simple image viewer. It does what it is supposed to, but if I open any image that is larger than my screens resolution then parts of the open image get cut off. I also cannot resize images. Could someone please help me ?? I would like to code the window so that it if the image is larger than my resolution (1920x1080) it is automatically scaled down to either fit the height or width. I'd also like images to scale to the window size if possible also. I've attached my code below. Sorry if this is a silly question, but I'm just starting out and slowly learning. Many thanks....


    Code:
    #include <gtk/gtk.h>
    
    void destroy(void) {
      gtk_main_quit();
    }
    
    int main (int argc, char** argv) {
      GtkWidget* window;
      GtkWidget* image;
    
      gtk_init (&argc, &argv);
    
    
      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
      image  = gtk_image_new_from_file(argv[1]);
    
      gtk_signal_connect(GTK_OBJECT (window), "destroy",
                 GTK_SIGNAL_FUNC (destroy), NULL);
    
      gtk_container_add(GTK_CONTAINER (window), image);
    
      gtk_widget_show_all(window);
    
      gtk_main();
    
      return 0;
    }
    Last edited by unknownvoid001; 01-24-2020 at 07:48 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. get window handle or screen DC of logon screen
    By Elkvis in forum Windows Programming
    Replies: 1
    Last Post: 01-21-2014, 01:47 PM
  2. Screen Width and Height
    By Benji Wiebe in forum Windows Programming
    Replies: 1
    Last Post: 06-11-2011, 03:06 AM
  3. scaling controls on window resize or font change?
    By Viper187 in forum Windows Programming
    Replies: 2
    Last Post: 07-13-2009, 01:14 PM
  4. Docking a Window to screen
    By LIJI in forum Windows Programming
    Replies: 2
    Last Post: 06-02-2007, 01:26 PM
  5. Replies: 3
    Last Post: 07-16-2002, 02:55 PM

Tags for this Thread