ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ImageIO.write(bufferedImage, "jpg", bos);
} catch (IOException e) {
throw new RuntimeException(e);
}
byte[] bytes = bos.toByteArray();
try (
Socket socket = new Socket("127.0.0.1", 8001);
OutputStream outputStream = socket.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(outputStream)
);
) {
writer.write("file");
writer.newLine();
writer.write(Integer.toString(bytes.length));
writer.newLine();
for (int i = 0; i < bytes.length; i++) {
writer.write(String.format("\\x%02X", (bytes[i])));
}
writer.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
QByteArray messageData;
QByteArray data = socket->readAll();
messageData.append(data);
QString filePath = "";
saveByteArrayAsJpg(messageData, filePath); // моя функция которая сохраняет изображение
"\xFF\xD8\xFF\xE0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xFF\xDB\x00""C\x00\b\x06\x06\x07\x06\x05\b\x07\x07\x07\t\t\b\n\f\x14\r\f\x0B\x0B\f\x19\x12\x13\x0F\x14\x1D\x1A\x1F\x1E\x1D\x1A\x1C\x1C $.' \",#\x1C\x1C(7),01444\x1F'9=82<.342\xFF\xDB\x00""C\x01\t\t\t\f\x0B\f\x18\r\r\x18""2!\x1C!22222222222222222222222222222222222222222222222222\xFF\xC0\x00\x11\b\x00=\x00K\x03\x01\"\x00\x02\x11\x01\x03\x11\x01\xFF\xC4\x00\x1F\x00\x00\x01\x05\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\xFF\xC4\x00\xB5\x10\x00\x02\x01\x03\x03\x02\x04\x03\x05\x05\x04\x04\x00\x00\x01}\x01\x02\x03\x00\x04\x11\x05\x12!1A\x06\x13Qa\x07\"q\x14""2\x81\x91\xA1\b#B\xB1\xC1\x15R\xD1\xF0$3br\x82\t\n\x16\x17\x18\x19\x1A%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x83\x84\x85\x86\x87\x88\x89\x8A\x92\x93\x94\x95\x96\x97\x98\x99\x9A\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFF\xC4\x00\x1F\x01\x00\x03\x01\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\xFF\xC4\x00\xB5\x11\x00\x02\x01\x02\x04\x04\x03\x04\x07\x05\x04\x04\x00\x01\x02w\x00\x01\x02\x03\x11\x04\x05!1\x06\x12""AQ\x07""aq\x13\"2\x81\b\x14""B\x91\xA1\xB1\xC1\t#3R\xF0\x15""br\xD1\n\x16$4\xE1%\xF1\x17\x18\x19\x1A&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x92\x93\x94\x95\x96\x97\x98\x99\x9A\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFF\xDA\x00\f\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xF3\x06#\x1C`\x9E\xDE\xC6\x99\xBC\x1C\x03\x9C\xFA""c\xFC\xFB\xD3Xd\x91\xBB\xAF\x1C\xFE_\xE3Mi8\xC1\xFCI\x1C\x7F\x9F\xF3\xCD\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xBB\f\xB3rX\xF5\xA0\x00s\xC9\xE0\x7FJq\xE4\xE7&\x93""4P\x00\xF8\xC7\x1D\x0F\xAD""DW\xF1\xFC:\xFF\x00\x9C\xD4\xB9'\x00\xF6\xE2\x91\x80=G\x03\xB5\x00W+\x9C\x9Cu\xFC\xBF\xCF?\xA5hho\x14Z\xB4""3\xCB+F\x91\xFC\xE0\xE3\xB8\xE9\xFD?*\xAA\xEA""6\x8C\xF2zs\xF5\xC7\xF5\xA8\xC0\x1E`\x19<\x93\xDF\xF1\xFE\xB4\x00\x97\x0En.\xE5\x94\x9C\x97s\x93\x8E\xB4\xD5\x1D\x01=\b\xE7\xF3\xFF\x00\xEB\x9Ax\x8C\x00""1\xC6I\x07\xF5\xA7*\x13\x92[\xB9\x1D;\xFA\xD0\x00\xA3\x0E\xA0}\x0F\xB5I\xCEz\xFE\x94\x98\xC8\x18""8\x02\xA5""e\x11\xED=I\x01\xA8\x02""0N\xF0""1\x9C\xF4\x19\xFF\x00>\xB4\xEC\xFD?*j\r\xEC""3\xFD\xE2\x07\xE7\x8A""6\x93\xCE\xE2(\x03\xFF\xD9"
\\xFF\\xD8\\xFF\\xE0\\x00\\x10\\x4A\\x46\\x49\\x46\\x00\\x01\\x02\\x00\\x00\\x01\\x00\\x01\\x00\\x00\\xFF\\xDB\\x00\\x43\\x00\\x08\\x06\\x06\\x07\\x06\\x05\\x08\\x07\\x07\\x07\\x09\\x09\\x08\\x0A\\x0C\\x14\\x0D\\x0C\\x0B\\x0B\\x0C\\x19\\x12\\x13\\x0F\\x14\\x1D\\x1A\\x1F\\x1E\\x1D\\x1A\\x1C\\x1C\\x20\\x24\\x2E\\x27\\x20\\x22\\x2C\\x23\\x1C\\x1C\\x28\\x37\\x29\\x2C\\x30\\x31\\x34\\x34\\x34\\x1F\\x27\\x39\\x3D\\x38\\x32\\x3C\\x2E\\x33\\x34\\x32\\xFF\\xDB\\x00\\x43\\x01\\x09\\x09\\x09\\x0C\\x0B\\x0C\\x18\\x0D\\x0D\\x18\\x32\\x21\\x1C\\x21\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\xFF\\xC0\\x00\\x11\\x08\\x00\\x3D\\x00\\x4B\\x03\\x01\\x22\\x00\\x02\\x11\\x01\\x03\\x11\\x01\\xFF\\xC4\\x00\\x1F\\x00\\x00\\x01\\x05\\x01\\x01\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\xFF\\xC4\\x00\\xB5\\x10\\x00\\x02\\x01\\x03\\x03\\x02\\x04\\x03\\x05\\x05\\x04\\x04\\x00\\x00\\x01\\x7D\\x01\\x02\\x03\\x00\\x04\\x11\\x05\\x12\\x21\\x31\\x41\\x06\\x13\\x51\\x61\\x07\\x22\\x71\\x14\\x32\\x81\\x91\\xA1\\x08\\x23\\x42\\xB1\\xC1\\x15\\x52\\xD1\\xF0\\x24\\x33\\x62\\x72\\x82\\x09\\x0A\\x16\\x17\\x18\\x19\\x1A\\x25\\x26\\x27\\x28\\x29\\x2A\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8A\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9A\\xA2\\xA3\\xA4\\xA5\\xA6\\xA7\\xA8\\xA9\\xAA\\xB2\\xB3\\xB4\\xB5\\xB6\\xB7\\xB8\\xB9\\xBA\\xC2\\xC3\\xC4\\xC5\\xC6\\xC7\\xC8\\xC9\\xCA\\xD2\\xD3\\xD4\\xD5\\xD6\\xD7\\xD8\\xD9\\xDA\\xE1\\xE2\\xE3\\xE4\\xE5\\xE6\\xE7\\xE8\\xE9\\xEA\\xF1\\xF2\\xF3\\xF4\\xF5\\xF6\\xF7\\xF8\\xF9\\xFA\\xFF\\xC4\\x00\\x1F\\x01\\x00\\x03\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\xFF\\xC4\\x00\\xB5\\x11\\x00\\x02\\x01\\x02\\x04\\x04\\x03\\x04\\x07\\x05\\x04\\x04\\x00\\x01\\x02\\x77\\x00\\x01\\x02\\x03\\x11\\x04\\x05\\x21\\x31\\x06\\x12\\x41\\x51\\x07\\x61\\x71\\x13\\x22\\x32\\x81\\x08\\x14\\x42\\x91\\xA1\\xB1\\xC1\\x09\\x23\\x33\\x52\\xF0\\x15\\x62\\x72\\xD1\\x0A\\x16\\x24\\x34\\xE1\\x25\\xF1\\x17\\x18\\x19\\x1A\\x26\\x27\\x28\\x29\\x2A\\x35\\x36\\x37\\x38\\x39\\x3A\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8A\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9A\\xA2\\xA3\\xA4\\xA5\\xA6\\xA7\\xA8\\xA9\\xAA\\xB2\\xB3\\xB4\\xB5\\xB6\\xB7\\xB8\\xB9\\xBA\\xC2\\xC3\\xC4\\xC5\\xC6\\xC7\\x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\\xF5\\xA8\\xC0\\x1E\\x60\\x19\\x3C\\x93\\xDF\\xF1\\xFE\\xB4\\x00\\x97\\x0E\\x6E\\x2E\\xE5\\x94\\x9C\\x97\\x73\\x93\\x8E\\xB4\\xD5\\x1D\\x01\\x3D\\x08\\xE7\\xF3\\xFF\\x00\\xEB\\x9A\\x78\\x8C\\x00\\x31\\xC6\\x49\\x07\\xF5\\xA7\\x2A\\x13\\x92\\x5B\\xB9\\x1D\\x3B\\xFA\\xD0\\x00\\xA3\\x0E\\xA0\\x7D\\x0F\\xB5\\x49\\xCE\\x7A\\xFE\\x94\\x98\\xC8\\x18\\x38\\x02\\xA5\\x65\\x11\\xED\\x3D\\x49\\x01\\xA8\\x02\\x30\\x4E\\xF0\\x31\\x9C\\xF4\\x19\\xFF\\x00\\x3E\\xB4\\xEC\\xFD\\x3F\\x2A\\x6A\\x0D\\xEC\\x33\\xFD\\xE2\\x07\\xE7\\x8A\\x36\\x93\\xCE\\xE2\\x28\\x03\\xFF\\xD9
void Server::saveByteArrayAsJpg(const QByteArray& byteArray, const QString& filePath)
{
QImage image;
if (image.loadFromData(byteArray)) {
// Ensure the file path has ".jpg" extension
QString filePathWithExtension = filePath;
if (!filePath.endsWith(".jpg", Qt::CaseInsensitive))
filePathWithExtension += ".jpg";
if (image.save(filePathWithExtension, "JPG")) {
qDebug() << "Image saved as .jpg file:" << filePathWithExtension;
} else {
qDebug() << "Error: Failed to save image as .jpg file.";
}
} else {
qDebug() << "Error: Failed to load image from QByteArray.";
}
}
А при отправке из Java я получаю такой:
\\xFF\\xD8\\xFF\\xE0\\x00\\x10\\x4A\\x46\\x49\\x46\\x00\\x01\\x02\\x00\\x00\\x01\\x00\\x01\\x00\\x00\\xFF\\xDB\\x00\\x43\\x00\\x08\\x06\\x06\\x07\\x06\\x05\\x08\\x07\\x07\\x07\\x09\\x09\\x08\\x0A\\x0C\\x14\\x0D\\x0C\\x0B\\x0B\\x0C\\x19\\x12\\x13\\x0F\\x14\\x1D\\x1A\\x1F\\x1E\\x1D\\x1A\\x1C\\x1C\\x20\\x24\\x2E\\x27\\x20\\x22\\x2C\\x23\\x1C\\x1C\\x28\\x37\\x29\\x2C\\x30\\x31\\x34\\x34\\x34\\x1F\\x27\\x39\\x3D\\x38\\x32\\x3C\\x2E\\x33\\x34\\x32\\xFF\\xDB\\x00\\x43\\x01\\x09\\x09\\x09\\x0C\\x0B\\x0C\\x18\\x0D\\x0D\\x18\\x32\\x21\\x1C\\x21\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\x32\\xFF\\xC0\\x00\\x11\\x08\\x00\\x3D\\x00\\x4B\\x03\\x01\\x22\\x00\\x02\\x11\\x01\\x03\\x11\\x01\\xFF\\xC4\\x00\\x1F\\x00\\x00\\x01\\x05\\x01\\x01\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\xFF\\xC4\\x00\\xB5\\x10\\x00\\x02\\x01\\x03\\x03\\x02\\x04\\x03\\x05\\x05\\x04\\x04\\x00\\x00\\x01\\x7D\\x01\\x02\\x03\\x00\\x04\\x11\\x05\\x12\\x21\\x31\\x41\\x06\\x13\\x51\\x61\\x07\\x22\\x71\\x14\\x32\\x81\\x91\\xA1\\x08\\x23\\x42\\xB1\\xC1\\x15\\x52\\xD1\\xF0\\x24\\x33\\x62\\x72\\x82\\x09\\x0A\\x16\\x17\\x18\\x19\\x1A\\x25\\x26\\x27\\x28\\x29\\x2A\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8A\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9A\\xA2\\xA3\\xA4\\xA5\\xA6\\xA7\\xA8\\xA9\\xAA\\xB2\\xB3\\xB4\\xB5\\xB6\\xB7\\xB8\\xB9\\xBA\\xC2\\xC3\\xC4\\xC5\\xC6\\xC7\\xC8\\xC9\\xCA\\xD2\\xD3\\xD4\\xD5\\xD6\\xD7\\xD8\\xD9\\xDA\\xE1\\xE2\\xE3\\xE4\\xE5\\xE6\\xE7\\xE8\\xE9\\xEA\\xF1\\xF2\\xF3\\xF4\\xF5\\xF6\\xF7\\xF8\\xF9\\xFA\\xFF\\xC4\\x00\\x1F\\x01\\x00\\x03\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\xFF\\xC4\\x00\\xB5\\x11\\x00\\x02\\x01\\x02\\x04\\x04\\x03\\x04\\x07\\x05\\x04\\x04\\x00\\x01\\x02\\x77\\x00\\x01\\x02\\x03\\x11\\x04\\x05\\x21\\x31\\x06\\x12\\x41\\x51\\x07\\x61\\x71\\x13\\x22\\x32\\x81\\x08\\x14\\x42\\x91\\xA1\\xB1\\xC1\\x09\\x23\\x33\\x52\\xF0\\x15\\x62\\x72\\xD1\\x0A\\x16\\x24\\x34\\xE1\\x25\\xF1\\x17\\x18\\x19\\x1A\\x26\\x27\\x28\\x29\\x2A\\x35\\x36\\x37\\x38\\x39\\x3A\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x73\\x74\\x75\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F6\\xE2\\x91\\x80\\x3D\\x47\\x03\\xB5\\x00\\x57\\x2B\\x9C\\x9C\\x75\\xFC\\xBF\\xCF\\x3F\\xA5\\x68\\x68\\x6F\\x14\\x5A\\xB4\\x33\\xCB\\x2B\\x46\\x91\\xFC\\xE0\\xE3\\xB8\\xE9\\xFD\\x3F\\x2A\\xAA\\xEA\\x36\\x8C\\xF2\\x7A\\x73\\xF5\\xC7\\xF5\\xA8\\xC0\\x1E\\x60\\x19\\x3C\\x93\\xDF\\xF1\\xFE\\xB4\\x00\\x97\\x0E\\x6E\\x2E\\xE5\\x94\\x9C\\x97\\x73\\x93\\x8E\\xB4\\xD5\\x1D\\x01\\x3D\\x08\\xE7\\xF3\\xFF\\x00\\xEB\\x9A\\x78\\x8C\\x00\\x31\\xC6\\x49\\x07\\xF5\\xA7\\x2A\\x13\\x92\\x5B\\xB9\\x1D\\x3B\\xFA\\xD0\\x00\\xA3\\x0E\\xA0\\x7D\\x0F\\xB5\\x49\\xCE\\x7A\\xFE\\x94\\x98\\xC8\\x18\\x38\\x02\\xA5\\x65\\x11\\xED\\x3D\\x49\\x01\\xA8\\x02\\x30\\x4E\\xF0\\x31\\x9C\\xF4\\x19\\xFF\\x00\\x3E\\xB4\\xEC\\xFD\\x3F\\x2A\\x6A\\x0D\\xEC\\x33\\xFD\\xE2\\x07\\xE7\\x8A\\x36\\x93\\xCE\\xE2\\x28\\x03\\xFF\\xD9
for (int i = 0; i < bytes.length; i++) { writer.write(String.format("\\x%02X", (bytes[i]))); }
QByteArray messageData;
while (socket->bytesAvailable( )) {
QString qq = socket->readLine();
qq.remove(qq.size()-2, 2);
qint32 s = (qq).toInt();
QByteArray data = QByteArray::number(s, 16);
qDebug() << data;
messageData.append(s);
}