コード例 #1
0
ファイル: iimport.cpp プロジェクト: soapdog/livecode
IO_stat MCImage::import(MCStringRef newname, IO_handle stream, IO_handle mstream)
{
	bool t_success = true;

	MCImageCompressedBitmap *t_compressed = nil;
	MCImageBitmap *t_bitmap = nil;
	MCStringRef t_name = nil;
	MCPoint t_hotspot = {1, 1};
    
	t_success = MCImageImport(stream, mstream, t_hotspot, t_name, t_compressed, t_bitmap);

	if (t_success)
	{
		if (t_compressed == nil)
			t_success = setbitmap(t_bitmap, 1.0);
		else
			t_success = setcompressedbitmap(t_compressed);
	}

	MCImageFreeCompressedBitmap(t_compressed);
	MCImageFreeBitmap(t_bitmap);

	uindex_t t_width, t_height;
	if (t_success)
		t_success = getsourcegeometry(t_width, t_height);

	if (t_success)
	{
		xhot = t_hotspot.x;
		yhot = t_hotspot.y;

		bool t_resize = true;
		t_resize = !(flags & F_LOCK_LOCATION);
		if (t_resize)
		{
			rect.width = t_width;
			rect.height = t_height;
		}

		if (m_rep->GetFrameCount() > 1)
		{
			if ((flags & F_REPEAT_COUNT) == 0)
				repeatcount = -1;
			irepeatcount = repeatcount;
			state |= CS_DO_START;
		}

		if (isunnamed() && t_name != nil)
        {
            MCNewAutoNameRef t_name_nameref;
            /* UNCHECKED */ MCNameCreate(t_name, &t_name_nameref);
			setname(*t_name_nameref);
        }
		if (isunnamed() && newname != nil)
		{
            MCNewAutoNameRef t_name_nameref;
            uindex_t t_offset;
            if (MCStringLastIndexOfChar(newname, PATH_SEPARATOR, UINDEX_MAX, kMCCompareExact, t_offset))
            {
                /* UNCHECKED */ MCStringCopySubstring(newname, MCRangeMakeMinMax(t_offset + 1, MCStringGetLength(newname)), t_name);
                /* UNCHECKED */ MCNameCreate(t_name, &t_name_nameref);
            }
            else
                /* UNCHECKED */ MCNameCreate(newname, &t_name_nameref);

			setname(*t_name_nameref);
		}
	}

	MCValueRelease(t_name);

	return t_success ? IO_NORMAL : IO_ERROR;
}
コード例 #2
0
ファイル: iimport.cpp プロジェクト: Bjoernke/livecode
IO_stat MCImage::import(const char *newname, IO_handle stream, IO_handle mstream)
{
	bool t_success = true;

	MCImageCompressedBitmap *t_compressed = nil;
	MCImageBitmap *t_bitmap = nil;
	char *t_name = nil;
	MCPoint t_hotspot = {1, 1};

	t_success = MCImageImport(stream, mstream, t_hotspot, t_name, t_compressed, t_bitmap);

	if (t_success)
	{
		if (t_compressed == nil)
			t_success = setbitmap(t_bitmap);
		else
			t_success = setcompressedbitmap(t_compressed);
	}

	MCImageFreeCompressedBitmap(t_compressed);
	MCImageFreeBitmap(t_bitmap);

	uindex_t t_width, t_height;
	if (t_success)
		t_success = m_rep->GetGeometry(t_width, t_height);

	if (t_success)
	{
		xhot = t_hotspot.x;
		yhot = t_hotspot.y;

		bool t_resize = true;
		t_resize = !(flags & F_LOCK_LOCATION);
		if (t_resize)
		{
			rect.width = t_width;
			rect.height = t_height;
		}

		if (m_rep->GetFrameCount() > 1)
		{
			if ((flags & F_REPEAT_COUNT) == 0)
				repeatcount = -1;
			irepeatcount = repeatcount;
			state |= CS_DO_START;
		}

		if (isunnamed() && t_name != nil)
			setname_cstring(t_name);
		if (isunnamed() && newname != nil)
		{
			const char *tname = strrchr(newname, PATH_SEPARATOR);
			if (tname != NULL)
				tname += 1;
			else
				tname = newname;
			setname_cstring(tname);
		}

	}

	MCCStringFree(t_name);

	return t_success ? IO_NORMAL : IO_ERROR;
}