The picture in png format with a resolution of 48x48 with white background. I need to get it stretched to the size of 16x16 and a white background was transparent. To display the image I am using the code:
QWidget* Icon;
QPixmap ico1(":/icons/ico1.png");
QPalette pal;
pal.setBrush(Icon->backgroundRole(), QBrush(ico1));
Icon->setPalette(pal);
Icon->resize(16,16);
Thanks.
for transparency use setWindowOpacity
Related
My goal is to convert a pcx image to png. The pcx image has transparent background and white lines\sketch.
I tried converting it using the below:
magick convert abc.pcx abc.png
magick convert abc.pcx -flatten abc.png
magick convert abc.pcx -background white -flatten abc.png
I also tried doing it programmatically (which is my ultimate goal) but nothing
using (var magickImage = new MagickImage(file))
{
magickImage.Format = MagickFormat.Png;
// this one kind of works, it does make the background
// transparent but the lines\sketch has white lines and black
// (only at the sketch)
// where we need transparent background and black lines\sketch
// magickImage.FloodFill(MagickColors.Transparent, 0, 0);
var filePng = Path.ChangeExtension(file, ".png");
magickImage.Write(filePng);
}
FYI - when the .pcx image is opened in adobe express shows correctly - transparent background with black lines.
When opened in ImageMagick (IMDisplay) shows black background with white lines.
Here is the link with the .pcx and the converted .png
https://drive.google.com/file/d/1x2fWswUFWL6hrLRCW1zuztC1Cry-QDqY/view?usp=sharing
Any ideas what i need to do?
I have a text image and I want to overlay it over a scene image, both having the same size and in RGB mode. I have tried the ImageChops OR operation but it seems to only work on binary (mode '1'). ImageChops.add_modulo and blend functions also did not help at all. What I need is to replace the pixel values in the scene image with those from the text image. The text image has 0 (black background) and the text has the value of 255. So, the overlay should be crystal clear, although scene images are in color.
I would appreciate any help on this issue.
I managed to do it as follows:
scene_image.paste(text_img, box=None, mask=text_img.convert('1'))
I tried this code to modify svg image to png
filename = 'hello';
inkscapepath = '"my inkscape path"';
system( [inkscapepath ' ' filename ...
'.svg --export-area-drawing --export-png=' filename '.png'])
It will create a hello.png file.
If I open it with windows picture viewer it is looking fine.The same content is present.
svg image is in png form but resolution changed from 100x100px to 60x8.
But to view it in MATLAB if use
imshow('hello.png')
A fully black image is coming as output figure.
the image matrix contains all the entries equal to 0
This answer is based on a guess that the file only contains a black image on a transparent background
Such as this one:
-it's in a spoiler to show transparency
With imshow Matlab replaces transparent pixels with black, to avoid this we can use imread to load in the image with additional options to set transparent pixels to white and then use imshow
RGB = imread('hello.png', 'BackgroundColor', [1,1,1] );
imshow(RGB);
Figure from passing the filename to imshow
Figure from setting transparent pixels to white
am using fabricjs library to crop images, i set freedrawing property to true to draw on images. how can i make this drawing transparent so the image still appear ?
Thanks
I am trying to save a png file in database using C#.
Bitmap thumbnail = new Bitmap(file.InputStream);
thumbnail = ImageUtilities.ResizeImage(thumbnail, Convert.ToInt32(width),Convert.ToInt32(height)); ImageUtilities.SaveJpeg(path,thumbnail,Convert.ToInt32(Resources.AppConstants.ExtractThumbnailQuality);
The image gets saved in database, but with a black background around the image. In short, it loses its transparency.
If I skip the resizing of image, instead of black background, a white background appears around the image.
Can anyone suggest, how to preserve the tranparency of the image
You are saving the resized image as JPEG. JPEG does not support transparency. Save it as PNG instead