문제

저는 현재 QT와 함께 스테 가노 그래피 응용 프로그램을 작성하는 중입니다. 픽셀의 파란색 색상에서 메시지 비트를 숨기려고합니다.

디버깅 에서이 섹션이 작동하는대로 작동한다고 말할 수 있습니다. 그러나 메시지에 비트를 숨긴 후 이미지를 저장 한 다음 다시 열었습니다. 문제가 발생하는 곳입니다.

내가 (다시 열린) 이미지를 읽을 때 scanLines 내가 읽은 것은 이전에 쓴 것과 같지 않으며 그 이유를 알 수 없습니다. 어쩌면 그것은 단지 내가 어리석은 것일 수도 있고, 아마도 뭔가를 놓치고있을 수도 있습니다. 어떤 도움이든 큰 감사를드립니다.

지금까지 가지고있는 코드는 다음과 같습니다

void MainWindow::Encrypt(QImage image, QString message) {
    if(image.isNull()) {
        qDebug() << "PROBLEM";
    }

    image = image.convertToFormat(QImage::Format_ARGB32);

    QVector<bool> bvec;
    QByteArray bytes = message.toAscii();
    char mask;
    QRgb tempPix;

    for(int i = 0; i < bytes.size(); i++) {
        for(int j = 0; j < 8; j++) {
            mask = (0x01 << j);
            bvec.push_back((bytes[i] & mask) == mask);
        }
    }

    if(image.height() < bvec.size()) {
        qDebug() << "Not enough space in image";
    }

    for(int j = 0; j < bvec.size(); j++) {
        QRgb *pixel = (QRgb *)image.scanLine(j);
        tempPix = *pixel;
        int blue = qBlue(tempPix);

        blue &= 0xFE;
        blue |= (bvec[j] == 1) ? 0x01 : 0x00;
        *pixel = qRgba(qRed(tempPix), qGreen(tempPix), blue, qAlpha(tempPix));
    }

    if(image.save(filename) != true) {
       emit addToStatusLog("Did not save. Error");
    }   
}

void MainWindow::Decrypt(QImage image) {
    char temp = 0x00;
    qint8 mask = 0x01;
    QVector<bool> bvec;
    QRgb *pixel;
    int blue;

    image = image.convertToFormat(QImage::Format_ARGB32);

    for(int i = 0; i < image.height(); i++) {
        pixel = (QRgb *)image.scanLine(i);
        blue = qBlue(*pixel);
        bvec.push_back((blue & mask) == mask);
    }

     for(int j = 0; j < bvec.size(); j++) {
        if(j % 8 == 0 && j != 0) {
            qDebug() << temp;
            temp = 0x00;
        }
        temp |= (bvec[j]) ? (0x01 << (j%8)) : 0x00;
    }

    qDebug() << temp;
}

감사

도움이 되었습니까?

해결책

JPEG와 같은 손실 형식을 사용하여 저장하지 않도록하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top