+// writes a picture as at most size bytes of data
+// message:
+// IMGNAME \0 SIZE(short) IMGDATA
+// if failed to read/compress:
+// IMGNAME \0 \0 \0
+//#501 void(float dest, string name, float maxsize) WritePicture (DP_SV_WRITEPICTURE))
+static void VM_SV_WritePicture (void)
+{
+ const char *imgname;
+ void *buf;
+ size_t size;
+
+ VM_SAFEPARMCOUNT(3, VM_SV_WritePicture);
+
+ imgname = PRVM_G_STRING(OFS_PARM1);
+ size = PRVM_G_FLOAT(OFS_PARM2);
+ if(size > 65535)
+ size = 65535;
+
+ MSG_WriteString(WriteDest(), imgname);
+ if(Image_Compress(imgname, size, &buf, &size))
+ {
+ // actual picture
+ MSG_WriteShort(WriteDest(), size);
+ SZ_Write(WriteDest(), buf, size);
+ }
+ else
+ {
+ // placeholder
+ MSG_WriteShort(WriteDest(), 0);
+ }
+}
+