Results 1 to 20 of 20

Thread: Display and divide the image

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Posts
    19
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default hi i want some help to display and divide image

    hi
    i m kiran suryawanshi
    i m final year student i m working on the project called as "tiled image viewer"
    In this i suppose to display image on tiled display i.e four monitors clustered together
    for that i hv to display and divide the image
    so i write the following code but i had problem saying that "Segmentation fault"

    i m represting problem area btn <problem></problem> tag
    plz help me
    Qt Code:
    1. #include "qgl.h"
    2. #include "qapplication.h"
    3. #include "qimage.h"
    4. #include "iostream.h"
    5. #include "GL/gl.h"
    6. class Radha : public QGLWidget
    7. {
    8. public:
    9. Radha(const QString &filename,QWidget *parent=0);
    10. void paintGL();
    11. void resizeGL(int w,int h);
    12. void divide();
    13. protected:
    14. QImage data,gldata;
    15. };
    16.  
    17. Radha::Radha(const QString &filename,QWidget *parent):QGLWidget(parent){
    18. data.load(filename);
    19. gldata=QGLWidget::convertToGLFormat(data);
    20. resize(data.size());
    21.  
    22. }
    23.  
    24. void Radha::paintGL(){
    25. int k,i,j,count=0,flag=1;
    26. <PROBLEM>
    27. uchar *temp;
    28. uchar *img;
    29. temp=gldata.bits();
    30.  
    31. for(j=0;j<data.width()*data.height();j++){ //for reading the half image in img array
    32. if(count==data.width()/2){
    33. flag==1-flag;
    34. count=0;
    35. }
    36. if(flag==1)
    37. img[j++]=temp[i];
    38. count++;
    39. }
    40.  
    41. glDrawPixels(data.width(),data.height(),GL_RGBA,GL_UNSIGNED_BYTE,img);
    42.  
    43. }
    44.  
    45.  
    46. void Radha::resizeGL(int w,int h){
    47. glViewport(0,0,w,h);
    48. glMatrixMode(GL_PROJECTION);
    49. glLoadIdentity();
    50. glOrtho(0,w,0,h,-1,1);
    51. glMatrixMode(GL_MODELVIEW);
    52.  
    53. }
    54.  
    55. int main(int argc,char** argv){
    56. QApplication app(argc,argv);
    57. Radha pw(argv[1]);
    58. pw.showFullScreen();
    59. return app.exec();
    60. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 2nd March 2007 at 15:38. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.