static nsresult WriteImage(const nsCString& aPath, gfxIImageFrame* aImage) { nsCOMPtr<nsIImage> img(do_GetInterface(aImage)); if (!img) return NS_ERROR_NOT_AVAILABLE; #ifndef MOZ_WIDGET_GTK2 return NS_ERROR_NOT_AVAILABLE; #else nsCOMPtr<nsIGdkPixbufImage> pixImg(do_QueryInterface(img)); if (!pixImg) return NS_ERROR_NOT_AVAILABLE; GdkPixbuf* pixbuf = pixImg->GetGdkPixbuf(); if (!pixbuf) return NS_ERROR_NOT_AVAILABLE; gboolean res = gdk_pixbuf_save(pixbuf, aPath.get(), "png", NULL, NULL); aImage->UnlockImageData(); g_object_unref(pixbuf); return res ? NS_OK : NS_ERROR_FAILURE; #endif }
void QCandy::setType(int cat, int eff) { this->cat = cat; this->eff = eff; switch (cat) { case 0: color = " "; type = " "; isCandy = false; break; case 1: color = "red"; if (eff == 0) type = ":/Picture/Original/Red.png"; else if (eff == 1) type = ":/Picture/Striped/Striped_red_h.png"; else if (eff == 2) type = ":/Picture/Striped/Striped_red_v.png"; else if (eff == 3) type = ":/Picture/Wrapped/Wrapped_red.png"; break; case 2: color = "blue"; if (eff == 0) type = ":/Picture/Original/Blue.png"; else if (eff == 1) type = ":/Picture/Striped/Striped_blue_h.png"; else if (eff == 2) type = ":/Picture/Striped/Striped_blue_v.png"; else if (eff == 3) type = ":/Picture/Wrapped/Wrapped_blue.png"; break; case 3: color = "green"; if (eff == 0) type = ":/Picture/Original/Green.png"; else if (eff == 1) type = ":/Picture/Striped/Striped_green_h.png"; else if (eff == 2) type = ":/Picture/Striped/Striped_green_v.png"; else if (eff == 3) type = ":/Picture/Wrapped/Wrapped_green.png"; break; case 4: color = "yellow"; if (eff == 0) type = ":/Picture/Original/Yellow.png"; else if (eff == 1) type = ":/Picture/Striped/Striped_yellow_h.png"; else if (eff == 2) type = ":/Picture/Striped/Striped_yellow_v.png"; else if (eff == 3) type = ":/Picture/Wrapped/Wrapped_yellow.png"; break; case 5: color = "orange"; if (eff == 0) type = ":/Picture/Original/Orange.png"; else if (eff == 1) type = ":/Picture/Striped/Striped_orange_h.png"; else if (eff == 2) type = ":/Picture/Striped/Striped_orange_v.png"; else if (eff == 3) type = ":/Picture/Wrapped/Wrapped_orange.png"; break; case 6: color = "purple"; if (eff == 0) type = ":/Picture/Original/Purple.png"; else if (eff == 1) type = ":/Picture/Striped/Striped_purple_h.png"; else if (eff == 2) type = ":/Picture/Striped/Striped_purple_v.png"; else if (eff == 3) type = ":/Picture/Wrapped/Wrapped_purple.png"; break; case 7: color = "colour"; type = ":/Picture/Colour Bomb/ColourBomb.png"; break; } QPixmap pixImg(type); setPixmap(pixImg); }