Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Problems with image colortable from latin1 file

$
0
0
Hello, I wrote some Raw-Image-Reader and most of it works. But I still cant figure out how to set the colortable correctly. So first of all here is my code example: QFile file(”:/new/1.raw”); //open file dialog if(file.open(QIODevice::ReadOnly)){qDebug(“File opened”);} else{qDebug(“File not opened”);} QByteArray ba=file.readAll(); //read file into bytearray QImage image(512,256,QImage::Format_Indexed8); //setup the blank image for pixel transfer later QVector<QRgb> colorTable; //setup the 8 bit grayscale colortable for(int i=0;i<256;i++) colorTable.push_back(qRgb(i,i,i)); image.setColorTable(colorTable); image.fill(0); //just displaying a blank image here QPixmap pix1(QPixmap::fromImage(image)); ui->label->setPixmap(pix1); int j=0; //image manipulation procedure for(int y=0;y<image.height();y++){ for(int x=0;x<image.width();x++){image.setPixel(x,y,ba.at( j)+128); j++;}} // I add +128 because the image file give me values from -128…127 QPixmap pix2(QPixmap::fromImage(image)); //display the file image on second pixmap here ui->label_4->setPixmap(pix2); So like I said most of it works, but it displays half of the image in a very dark colors and some other parts looking extremly bright. I’m pretty sure I did something wrong with the file itself, maybe it contains some special code. I thought it is just ascii, but my Geany-Editor encodes it with ISO-8859-1. So I guess I need to convert from Latin1 to ascii or something else. Here is a example from the beginning of the file: ÷=!<qÜáßåçëçìñîîìïñîòöñöø� �ÿúùüøýüûýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ� �ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ� �ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ� �ùÿúôæêèçÜÙØ×ØÔÒÍÉÁÈÅÇËÈÃ� �ÄÂÁÂÂÅÈÍÏÑÈÇÅÇÍÑÓÓÏÒ×ÙÖÚ� �àâáâáäÜåçèíîîòóöÿÿûÿÿÿýû� �ÿÿÿÿÿÿÿÿÿÿÿÿÿ Hope someone got a hint for me to set the display correct, so that I could finish this stuff. Best reagrds, Olli

Viewing all articles
Browse latest Browse all 13965

Trending Articles