Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Andreas Kempe
mpi-mandelbrot
Commits
a28bf5d2
Commit
a28bf5d2
authored
Oct 03, 2015
by
Andreas Kempe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
It is now possible to show and send images.
parent
63a7a3b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
client/main_window.cpp
client/main_window.cpp
+3
-10
network/network_defines.h
network/network_defines.h
+5
-1
No files found.
client/main_window.cpp
View file @
a28bf5d2
...
...
@@ -62,25 +62,18 @@ void main_window::handle_recv_data()
{
data_packet
*
packet
=
socket
->
get_next_packet
();
//TODO: Handle packet!
qDebug
()
<<
"Received a packet!"
;
switch
(
packet
->
get_op_code
())
{
case
op_codes
::
IMG_DATA
:
{
qDebug
()
<<
"Received a data packet with op code IMG_DATA and a payload of size "
<<
packet
->
get_payload_size
()
<<
" byte(s)."
;
Magick
::
Image
recv_img
;
// Get the image from the packet and display it.
std
::
string
enc_img
(
packet
->
get_payload
());
Magick
::
Blob
blob
;
blob
.
base64
(
enc_img
);
recv_img
.
read
(
blob
);
recv_img
.
write
(
"output.png"
);
qDebug
()
<<
"Saved the image as
\"
output.png
\"
!"
;
mandel_image
->
loadFromData
((
const
uchar
*
)
blob
.
data
(),
blob
.
length
());
item
->
setPixmap
(
QPixmap
::
fromImage
(
*
mandel_image
));
}
}
...
...
network/network_defines.h
View file @
a28bf5d2
...
...
@@ -6,7 +6,11 @@
enum
op_codes
:
quint32
{
IMG_DATA
=
0x1
/* Used to send image data to the client.
* The image should be in the payload
* encoded as base64 using ImageMagicks
* Blob-class. */
IMG_DATA
=
0x1
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment