Exemplo n.º 1
0
IO_stat IO_write_mccolor(const MCColor& p_color, IO_handle p_stream)
{
	IO_stat t_stat;
	t_stat = IO_NORMAL;

	if (t_stat == IO_NORMAL)
		t_stat = IO_write_uint2(p_color . red, p_stream);

	if (t_stat == IO_NORMAL)
		t_stat = IO_write_uint2(p_color . green, p_stream);

	if (t_stat == IO_NORMAL)
		t_stat = IO_write_uint2(p_color . blue, p_stream);

	return t_stat;
}
Exemplo n.º 2
0
IO_stat IO_write_uint2or4(uint4 dest, IO_handle stream)
{
	// If we are writing out a value < 16384, we only need one 2-byte word.
	if (dest < 16384)
		return IO_write_uint2(dest, stream);
		
	// Write out the lowest 15 bits of the value, marking it as having another
	// word by setting the top bit.
	IO_stat t_stat;
	t_stat = IO_write_uint2((dest & 0x7fff) | 0x8000, stream);
	
	// Now write out the remaining 16 top bits.
	if (t_stat == IO_NORMAL)
		t_stat = IO_write_uint2(dest >> 15, stream);
	
	return t_stat;
}
Exemplo n.º 3
0
IO_stat MCEPS::save(IO_handle stream, uint4 p_part, bool p_force_ext)
{
	IO_stat stat;

	if ((stat = IO_write_uint1(OT_MCEPS, stream)) != IO_NORMAL)
		return stat;
	if ((stat = MCObject::save(stream, p_part, p_force_ext)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint4(size, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write(postscript, sizeof(char), size, stream)) != IO_NORMAL)
		return stat;
	// MW-2013-11-19: [[ UnicodeFileFormat ]] EPS is always ASCII so legacy.
	if ((stat = IO_write_cstring_legacy(prolog, stream, 2)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_int4(MCU_r8toi4(xscale), stream)) != IO_NORMAL)
		return stat;
	if (flags & F_SCALE_INDEPENDENTLY)
		if ((stat = IO_write_int4(MCU_r8toi4(yscale), stream)) != IO_NORMAL)
			return stat;
	if ((stat = IO_write_int2(angle, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_int2(tx, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_int2(ty, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint2(ex, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint2(ey, stream)) != IO_NORMAL)
		return stat;
	if (flags & F_RETAIN_IMAGE)
		if ((stat = image->save(stream, p_part, p_force_ext)) != IO_NORMAL)
			return stat;
	if ((stat = IO_write_uint2(curpage, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint2(pagecount, stream)) != IO_NORMAL)
		return stat;
	uint2 i;
	for (i = 0 ; i < pagecount ; i++)
		if ((stat = IO_write_uint4(pageIndex[i], stream)) != IO_NORMAL)
			return stat;
	return savepropsets(stream);
}
Exemplo n.º 4
0
IO_stat MCLogicalFontTableSave(IO_handle p_stream)
{
	IO_stat t_stat;
	t_stat = IO_NORMAL;

	if (t_stat == IO_NORMAL)
		t_stat = IO_write_uint2(s_logical_font_table_size, p_stream);
	
	if (t_stat == IO_NORMAL)
		for(uint32_t i = 0; i < s_logical_font_table_size && t_stat == IO_NORMAL; i++)
		{
			MCNameRef t_textfont;
			uint2 t_textstyle;
			uint2 t_textsize;
			bool t_is_unicode;
			MCLogicalFontTableGetEntry(i, t_textfont, t_textstyle, t_textsize, t_is_unicode);

			if (t_textfont == nil)
				t_textfont = kMCEmptyName;

			t_stat = IO_write_uint2(t_textsize, p_stream);
			if (t_stat == IO_NORMAL)
				t_stat = IO_write_uint2(t_textstyle, p_stream);
			if (t_stat == IO_NORMAL)
			{
				if (t_is_unicode)
				{
					char *t_unicode_textfont;
					t_unicode_textfont = new char[strlen(MCNameGetCString(t_textfont)) + 9];
					strcpy(t_unicode_textfont, MCNameGetCString(t_textfont));
					strcat(t_unicode_textfont, ",unicode");
					t_stat = IO_write_string(t_unicode_textfont, p_stream);
					delete t_unicode_textfont;
				}
				else
					t_stat = IO_write_string(MCNameGetCString(t_textfont), p_stream);
			}
		}

	return t_stat;
}
Exemplo n.º 5
0
IO_stat MCVideoClip::save(IO_handle stream, uint4 p_part, bool p_force_ext)
{
	IO_stat stat;

	if ((stat = IO_write_uint1(OT_VIDEO_CLIP, stream)) != IO_NORMAL)
		return stat;
	if ((stat = MCObject::save(stream, p_part, p_force_ext)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint4(size, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write(frames, sizeof(uint1), size, stream)) != IO_NORMAL)
		return stat;
	if (flags & F_FRAME_RATE)
		if ((stat = IO_write_uint2(framerate, stream)) != IO_NORMAL)
			return stat;
	if (flags & F_SCALE_FACTOR)
		if ((stat = IO_write_int4(MCU_r8toi4(scale), stream)) != IO_NORMAL)
			return stat;
	return savepropsets(stream);
}
Exemplo n.º 6
0
IO_stat IO_write_string(const MCString &p_string, IO_handle p_stream, uint8_t p_size, bool p_write_null)
{
	IO_stat stat = IO_NORMAL;
	uint32_t t_strlen = p_string.getlength();
	uint4 length = 0;
	uint32_t t_inc = p_write_null ? 1 : 0;
	switch (p_size)
	{
		case 1:
		{
			uint1 len = t_strlen == 0 ? 0 : MCU_min(t_strlen + t_inc, MAXUINT1);
			if ((stat = IO_write_uint1(len, p_stream)) != IO_NORMAL)
				return stat;
			length = len;
			break;
		}
		case 2:
		{
			uint2 len = t_strlen == 0 ? 0 : MCU_min(t_strlen + t_inc, MAXUINT2);
			if ((stat = IO_write_uint2(len, p_stream)) != IO_NORMAL)
				return stat;
			length = len;
			break;
		}
		case 4:
			length = t_strlen == 0 ? 0 : t_strlen + t_inc;
			if ((stat = IO_write_uint4(length, p_stream)) != IO_NORMAL)
				return stat;
			break;
	}
	if (length)
	{
		stat = MCStackSecurityWrite(p_string.getstring(), length - t_inc, p_stream);
		if (stat == IO_NORMAL && p_write_null)
			stat = IO_write_uint1(0, p_stream);
	}
	return stat;
}