"No Transparency on Visual Basic PictureBox" - vb6

This is in reference to:
No Transparency on Visual Basic PictureBox
To Visual Vincent; First, I'd like to thank you for sharing your efforts with the community... Thank you very much!
I'm not very good at "Class" building. I've never implemented class modules very efficiently. I understand the principals, but tussle with mapping the properties and events before creation.
Anyway, does this example work in VB6? If so, how?
When I paste your example code into the class module code window, much of the text is red.

You can try my AlphaBlendImage control for VB6 built-in VB.Image control replacement w/ added support for transparency.
It supports both key-color transparency where you choose one color (e.g. magenta) to become transparent and true alpha-channel transparency like in PNG files.
You have to load PNG files with it's GdipLoadPicture function to preserve the alpha-channel transparency still by using built-in StdPicture instances. Take a look at the sample in test/basic directory for more info.

Related

How to make QWidget background with specified png file?

MyDialog::MyDialog(QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
, _pixmap(new QPixmap(myPngFile))
{
QPalette palette;
palette.setBrush(this->backgroundRole(), QBrush(*_pixmap));
this->setPalette(palette);
setFixedSize(_pixmap->size());
}
myPngFile define the png path. The problem is the transparent part in png file showed black when I show MyDialog, how do I correct it to load myPngFile?
I am using Windows platform with Qt4.8
Please do not use stylesheet.
Use
setAttribute(Qt::WA_TranslucentBackground);
Take a look at this:
specifically:
QPixmap aPixmap(":/splash.png");
QLabel* aWidget = new QLabel(0, Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
aWidget->setAttribute(Qt::WA_TranslucentBackground);
aWidget->setPixmap(aPixmap);
aWidget->show();
And docs:
Creating Translucent Windows Since Qt 4.5, it has been possible to
create windows with translucent regions on window systems that support
compositing. To enable this feature in a top-level widget, set its
Qt::WA_TranslucentBackground attribute with setAttribute() and ensure
that its background is painted with non-opaque colors in the regions
you want to be partially transparent.
Platform notes:
X11: This
feature relies on the use of an X server that supports ARGB visuals
and a compositing window manager.
Windows: The widget needs to have
the Qt::FramelessWindowHint window flag set for the translucency to
work.
(This bold part you already do, but for future comers better to make it visible)
If you really don't want to use style sheets, your problem could be solved by overwriting the paint event of your MyDialog class like in the answer of this stackoverflow question:
Background image not showing on QWidget
But I would also recommend using style sheets for your problem.
I cannot understand why you do not want to use stylesheets since this it the preferred way. Use the setStylesheet method of QWidget
setStyleSheet("background-image: url(:/images/pixmap.png);");
Where pixmap.png will be located in the resource file under the images prefix. For more details check the Qt stylesheet examples.

Picture Transparency

How do I make a picture transparent in VB6.0 so that when I add image and put the picture, the background will show behind it?
From Rod Stephen's excellent VB Helper site (particularly good on graphics in VB6):
HowTo: Overlay one image on another with a transparent color by using PSet
Description from the site:
This program simply loops through the pixels in the images. For each
image in top-to-bottom order, the program looks for a color other than
the one defined as transparent. When it finds such a color, it stops
looking at the images and sets the output pixel's color using PSet.
Note that there are faster ways to access color values in V 6 and VB
.NET, and that there are faster methods for merging images if you have
an overlay mask. Note also that VB .NET provides tools for setting a
transparent color for an image so this problem is trivial in VB .NET.
i think you should use an ocx and dll library to fix it
You can use 3rd party .ocx files to get that effect.checkout this link http://www.vbforums.com/showthread.php?636390-vb6-Transparent-PictureBox

VS2010 Image library, what is the use of the different size pngs?

The VS2010 image library contains several pngs of standard icons (Warning, Error, ...) in different sizes side by side. What is the use of such a png?
Is it meant as source to cut the best size and save it as new png?
Or is there a way to use such a png and the best resolution is picked automatically. And if so, how is this done?
I wonder why there are such side-by-side images and not several files such as Warning32.png, Warning16.png ....
Example: Information.png
It is an old programming trick and it is exactly what you assume it to be. The bitmap is a "film roll" and to make it work you have to know the pitch of the images, the resource doesn't tell you. Hard-coded in the source code. Microsoft's source code, you got the copy of their work.

WP7 XNA: How to change size or style of SpriteFont fonts dynamically in code?

There seems no way to change font size or style in code, right?? It seems the only way is to duplicate the font files and load them all when program starts??
Thanks
SpriteFonts convert a font, with style, size, and other parameters, to a pixel-based format for use as a texture within XNA. Those pixels are static, so yes, there is no way to change them, short of looping through per pixel.
However there is scaling (though it won't look so great scaling larger) to help with size adjustments needed, plus you could, like you said, create multiple SpriteFont files from the same base font for different styles, and dynamically choose one of those sprite font "textures" within your code.
Beyond that, for true fully dynamic runtime usage, you'd need to essentially create these sprite font textures on the fly, in memory. This means you'd have to do what the SpriteFont Content Pipeline project does but at runtime instead. This is possible in WinForms, but as far as I know not really an option for WP7 as you apparently are using.

How to programmatically create a 'bright' and a 'gray' version of an icon?

In a win32 application, I want to have a button with an icon which looks gray when the button is disabled and 'brighter' when the mouse hovers.
I know I can create three bitmaps with an icon editor, but since the icon can be user selected and loaded from the disk, I would like to create the other two versions programmatically.
So, starting with a handle to an image, I would like to:
- Create a new image with all colors converted to grey.
- Create a new image with all colors shifted to white or yellow.
Can this be done using win32 api calls?
Examples in any language will be appreciated.
Maybe the good old DrawState function will suffice. (For some reason it is now listed as only available from Win2000 which is not true.)
And maybe not, in which case you might want to use SetColorAdjustment function.
If the icon is user-selected do you control the format? If not you'll probably want to incorporate an image library or external process like DevIL or Imagemagick which handle more formats than Microsofts API's are likely to..

Resources