summaryrefslogtreecommitdiff
path: root/src/lib/image.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-15 23:19:27 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-15 23:19:27 +0100
commite946a66554185459043af2a8bdae575e255c743d (patch)
tree42d7ee7da6f6646f91b5429ed20fe84db92387d8 /src/lib/image.cc
parent43990add893eccf350f280e2dd3f947a94f3e9aa (diff)
Unholy melange of stuff; setup a standard test config; send / receive subs to / from servers; various other image stride-related fixes.
Diffstat (limited to 'src/lib/image.cc')
-rw-r--r--src/lib/image.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc
index f5aef8444..30dc4292f 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -244,6 +244,30 @@ Image::alpha_blend (shared_ptr<Image> other, Position position)
}
}
+void
+Image::read_from_socket (shared_ptr<Socket> socket)
+{
+ for (int i = 0; i < components(); ++i) {
+ uint8_t* p = data()[i];
+ for (int y = 0; y < lines(i); ++y) {
+ socket->read_definite_and_consume (p, line_size()[i], 30);
+ p += stride()[i];
+ }
+ }
+}
+
+void
+Image::write_to_socket (shared_ptr<Socket> socket) const
+{
+ for (int i = 0; i < components(); ++i) {
+ uint8_t* p = data()[i];
+ for (int y = 0; y < lines(i); ++y) {
+ socket->write (p, line_size()[i], 30);
+ p += stride()[i];
+ }
+ }
+}
+
/** Construct a SimpleImage of a given size and format, allocating memory
* as required.
*