Jump to content

Toolbar icon doesn't load?


Go to solution Solved by Josh,

Recommended Posts

Posted

Occasionally the editor will display a white square on one or more toolbar buttons. I'm not sure if this is a Win32 problem or a problem with the SVG rasterizer.

Image1.png.cf1f7bf3a3bf9fdf1f95d382c12c1db3.png

Let's build cool stuff and have fun. :)

Posted

I replace Lock/Unlock bits with SetPixel and it seems to work correctly. No idea why but it doesn't seem any slower this way.

#ifdef _WIN32
	shared_ptr<Gdiplus::Bitmap> Pixmap::GetBitmap()
	{
		if (bitmap) return bitmap;

		auto pixmap = As<Pixmap>();
		int format = PixelFormat32bppPARGB;
		int bpp = 4;
		switch (m_format)
		{
		case TEXTURE_BGRA:
			break;
		case TEXTURE_BGR:
			bpp = 3;
			format = PixelFormat24bppRGB;
			break;
		default:
			pixmap = Convert(TEXTURE_BGRA);
			if (pixmap == NULL) return NULL;
			break;
		}
		auto bitmap = std::make_shared<Gdiplus::Bitmap>(size.x, size.y, format);
		unsigned char pixel[4] = { 0,0,0,255 };
		Gdiplus::Color color;
		/*
		Gdiplus::BitmapData data;
		Gdiplus::Rect rect = Gdiplus::Rect(0, 0, size.x, size.y);		
		auto stat = bitmap->LockBits(&rect, Gdiplus::ImageLockMode::ImageLockModeWrite, format, &data);
		if (stat != Gdiplus::Status::Ok) return NULL;
		memcpy(data.Scan0, pixmap->pixels->Data(), pixmap->pixels->GetSize());
		stat = bitmap->UnlockBits(&data);
		if (stat != Gdiplus::Status::Ok) return NULL;
		*/
		uint32_t rgba;
		for (int x = 0; x < size.x; ++x)
		{
			for (int y = 0; y < size.y; ++y)
			{
				rgba = pixmap->ReadPixel(x, y);
				if (format == TEXTURE_BGRA) rgba = Rgba(Blue(rgba), Green(rgba), Red(rgba), Alpha(rgba));
				color.SetValue(rgba);
				bitmap->SetPixel(x, y, color);
			}
		}
		this->bitmap = bitmap;
		return bitmap;
	}
#endif

 

Let's build cool stuff and have fun. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...