Skip to content

Commit caec3f4

Browse files
committed
Using network byte order to store color data
1 parent d5774eb commit caec3f4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

server/postpic.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
/* Others */
3838
#include <stdio.h>
3939
#include <unistd.h>
40+
#include <arpa/inet.h>
4041

4142
PG_MODULE_MAGIC;
4243

@@ -260,11 +261,11 @@ Datum image_new(PG_FUNCTION_ARGS)
260261

261262
ccs = color->cs;
262263
if(ccs == CS_RGB.oid || ccs == CS_sRGB.oid) {
263-
map = "BGRP";
264+
map = "PRGB";
264265
} else if(ccs == CS_RGBA.oid) {
265-
map = "ABGR";
266+
map = "RGBA";
266267
} else if(ccs == CS_CMYK.oid) {
267-
map = "KYMC";
268+
map = "CMYK";
268269
} else {
269270
elog(ERROR, "Unsupported colorspace %d", color->cs);
270271
PG_RETURN_NULL();
@@ -775,7 +776,7 @@ void pp_parse_color(const char * str, PPColor * color)
775776
strncpy(cs, str, i); cs[i]=0;
776777
strcpy(cd, str + i + 1);
777778

778-
color->cd = strtoll(cd, NULL, 16);
779+
color->cd = htonl(strtoll(cd, NULL, 16));
779780
if(!cs[0]) {
780781
color->cs = (strlen(cd)>6 ? CS_RGBA.oid : CS_RGB.oid);
781782
} else {

0 commit comments

Comments
 (0)