Results 1 to 5 of 5

Thread: Raster Image Loading

  1. #1
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Raster Image Loading

    Hello,

    I am working on development of a graphical application where in one can draw lines, circles, points, load images, scale them and rotate, zooom in and out...

    Well, I'm new to this world, but by hook or crook i am able to draw lines, polygons and load image. I'm also able to Zoom upto some extent. I am using wxWidgets for the GUI implementation Using C++.

    Here's my initialization of code for graphics.

    int w,h;

    GetClientSize(&w,&h); // function which returns the canvas's height and width
    glViewport( 0, 0, (GLint)w, (GLint)h);

    if(h==0) h=1;

    left=0;
    right=(double)w;
    top=(double)h;
    bottom=0;
    near=0;
    far=1;

    double aspect_ratio = (double)w/(double)h;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    if ( w > h)
    glOrtho( left*aspect_ratio, right*aspect_ratio, bottom, top, near, far);
    else
    glOrtho( left, right, bottom*aspect_ratio, top*aspect_ratio, near, far);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    Then later i catch the mouse scrolling event and write the following code:

    if( event.GetWheelRotation() < 0 )
    {
    left *= 0.75f;
    right *= 0.75f;
    bottom *= 0.75f;
    top *= 0.75f;
    near *= 0.75f;
    far *= 0.75f;
    }
    else
    {
    left *= 1.33f;
    right *= 1.33f;
    bottom *= 1.33f;
    top *= 1.33f;
    near *= 1.33f;
    far *= 1.33f;
    }

    int cw,ch;
    GetClientSize(&amp;w, &amp;h);
    double aspect_ratio = (double)w/(double)h;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    if ( w > h)
    glOrtho( left*aspect_ratio, right*aspect_ratio, bottom, top, near, far);
    else
    glOrtho( left, right, bottom*aspect_ratio, top*aspect_ratio, near, far);

    glMatrixMode(GL_MODELVIEW);
    this->Refresh(false);

    this event catching code is written for mouse scroll of canvas. It works absolutely fine.. But it zooms with reference to the origin only.. how do i do it with reference to the point where mouse is pointing to.??

    Secondly, when i load a high resolution image, it takes lot of time to zoom in / out.. in other applications it zooms very fast.. if i load low resolution image then it works file.. what can be done to improve this drawback..?? is there any way to reduce the resolution of the image before loading.??

    Thanks in advance

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649

    Re: Raster Image Loading

    Quote Originally Posted by rakesh_thp
    this event catching code is written for mouse scroll of canvas. It works absolutely fine.. But it zooms with reference to the origin only.. how do i do it with reference to the point where mouse is pointing to.??
    The usual way is to translate that point to the origin, scale, and then translate back (if desired).

    A scale implicitly about 0. So just change what's 0.

  3. #3
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Re: Raster Image Loading

    Well amd using true zooming method. as far as my knowledge is concerned, there is no scaling used in this. Well i was wondering if gluLookAt() will help me ore not here..

    Anyways, what about my first problem of image resolution.??

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649

    Re: Raster Image Loading

    Quote Originally Posted by rakesh_thp
    Well amd using true zooming method. as far as my knowledge is concerned, there is no scaling used in this. Well i was wondering if gluLookAt() will help me ore not here..
    Depending on how you're rendering you could use that.

    Anyways, what about my first problem of image resolution.??
    From your description, doesn't sound like an OpenGL problem. You're saying your loading (from disk?) is too slow. Yeah, you can precompute reduced res versions (say power-of-two reductions down to 1x1), store them on disk with the image, and then when you load, you can load them smallest to largest, and load each power-of-two larger image into a successively larger MIPmap level of the same texture. If you set the MIN_LOD and MAX_LOD on the texture so that only the levels you've loaded are used for rendering, you can show your users the texture well before the texture finishes loading. It'll just get "crisper" as successively larger MIPs load.

  5. #5
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Re: Raster Image Loading

    Actually the file which i was trying to load is having 96bpi and 1204*1455 ... it does loading and zooming.. but very slowly. on the other hand i tried with same res size 1204*1455, but with 24bpi file.. this works absolutely fine and much faster than the previous one..

Similar Threads

  1. Image Loading Library for loading image textures
    By jitendra2896 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-03-2017, 12:13 AM
  2. Loading an image??
    By Creative Mind in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-20-2009, 11:13 AM
  3. image loading
    By phamt78 in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 01-27-2008, 06:29 PM
  4. Replies: 2
    Last Post: 07-28-2003, 07:30 PM
  5. Loading Sun Raster images
    By lepp in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-24-2002, 03:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean