Ask Your Question
1

2 Images on the same FULLSCREEN window + their position

asked 2012-09-26 06:46:06 -0500

Despair gravatar image

Hi, I've tried creating a window that will display 2 images in it so I opened a new window using autosize ( that from what I read keeps the images size and prevents them from being fit to the window) but still all i have is 1 big image.

Goal : Displaying the current displayed picture on the left side of screen and a secondary image on the right side of the screen. ** the window will be set to be FULLSCREEN

*could use a suggestion about the way I open the window to be full screen and images the same size they started with * this is what I have so far:

#include "highgui.h"
#include "cv.h"
#include <iostream>
#define FILENAME "picture.jpg"
#define WINDOWTITLE "Image To Ascii"
int beta=255;

IplImage* img_gray=NULL,*img_gray_smaller=NULL,*img_gray_regular_size=NULL,*img_gray_modify=NULL;

void onTrackbarSlide(int pos){
    img_gray_modify=cvCreateImage(cvSize(80, 60),IPL_DEPTH_8U,1);
    cvCopy( img_gray_smaller, img_gray_modify, NULL );
    int inc=(pos<255)? 255-pos: -255+(510-pos);
    cvSetImageROI(img_gray_modify,cvRect(0,0,80,60));
    cvAddS(img_gray_modify, cvScalar(inc),img_gray_modify);
    cvResetImageROI(img_gray_modify);
    img_gray_regular_size=cvCreateImage(cvSize(800, 600),IPL_DEPTH_8U,1);
    cvResize(img_gray_modify,img_gray_regular_size,CV_INTER_NN);
    cvReleaseImage(&img_gray_modify);
    cvShowImage(WINDOWTITLE, img_gray_regular_size);
}

int main(){
    char c='a';
    img_gray=cvLoadImage(FILENAME,CV_LOAD_IMAGE_GRAYSCALE),
    img_gray_smaller=cvCreateImage(cvSize(80, 60),IPL_DEPTH_8U,1),
    cvNamedWindow(WINDOWTITLE, CV_WINDOW_AUTOSIZE | CV_WINDOW_NORMAL);
    //cvResizeWindow(WINDOWTITLE,800,600);
    cvCreateTrackbar("brightness", WINDOWTITLE, &beta, 510, onTrackbarSlide);
    while(true){
        c=cvWaitKey(0);
        if (c==27)break;
        if (c==32){
            cvReleaseImage(&img_gray_smaller);
            cvReleaseImage(&img_gray);
            cvReleaseImage(&img_gray_regular_size);
            img_gray=cvLoadImage(FILENAME,CV_LOAD_IMAGE_GRAYSCALE);
            img_gray_smaller=cvCreateImage(cvSize(80, 60),IPL_DEPTH_8U,1);
            cvResize(img_gray,img_gray_smaller,CV_INTER_LINEAR);
        }
        cvShowImage(WINDOWTITLE, img_gray_regular_size);    
    }
    cvReleaseImage(&img_gray_smaller);
    cvReleaseImage(&img_gray);
    cvReleaseImage(&img_gray_regular_size);
    cvReleaseImage(&img_gray_modify);
}
  • another thing : is there an efficient way to move the Trackbar to the bottom of the screen no matter which resolution i use?
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-09-28 10:26:17 -0500

Despair gravatar image

Okay so after a few hours of reading trying and failing, I've come to an conclusion that this can't be done.

Simple solution is : make a new bigger image and use the Region Of Interest to copy all the images you want to the bigger image and then display it.

Though I still have no idea how to move the Slidebar to a fixed position by window size :O

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-09-26 06:46:06 -0500

Seen: 1,128 times

Last updated: Sep 28 '12