Solved

Stretch and Transparent Picturebox

Posted on 2007-03-19
8
429 Views
Last Modified: 2008-01-09
I  have a public game that’s been out for 3 years now.
I have found that my program is not compatible with Windows Vista because there are 3 OCX files that do not register in vista. (assuming 16 bit versions).

I have managed to find 32 bit replacements for 2/3.
The one I have spent 5 days solid trying to find a replacement for is Transparentpicture.ocx.
The reason I cant find a replacement is because I need it to have 2 special features.

Stretching pictures larger or smaller and Transparent background ability at the same time

I have not been able to find a replacement ActiveX control so far.
I have found some that do either 1 or the other but not both at the same time.
i cannot use the Image control because my app uses Activeskin and image controls dont show up when skinned.
I have managed to find the code to stretch a picturebox control.

 So i have to find a way to have a transparent color in a picturebox or find a replacement ActiveX control that does both.


Win98/ME/2000/XP/Vista (32bit)
Visual Basic 6
0
Comment
Question by:kcmagicdata
  • 3
  • 2
8 Comments
 
LVL 22

Expert Comment

by:danaseaman
ID: 18753519
Following code supports most popular image formats, transparency, stretching, and rotation.
Also supports XP 32-bit images:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=67466&lngWId=1

It is not coded as an OCX but that would not be hard to implement or you could render to a Vb PictureBox.


0
 

Author Comment

by:kcmagicdata
ID: 18753722
Ive seen that code before and it is very in depth but it does not do the actual transparent background on a JPG it does tranparency like glass. And besides it would take me days to understand all the routines and code.

I have JPG images only that i want to make white or red backgrounds dissapear.
0
 
LVL 22

Expert Comment

by:danaseaman
ID: 18753789
First time I've heard of JPG with transparency. The glass effect your are referring to is the "Opaque" property which can be applied to any image type using the above code independent of Transparency.

See the following link:

Subject: [12] Can I make a transparent JPEG?

No.  JPEG does not support transparency and is not likely to do so any time
soon.  It turns out that adding transparency to JPEG would not be a simple
task; read on if you want the gory details.

http://www.faqs.org/faqs/jpeg-faq/part1/

I would suggest you convert to PNG but what appears as solid red or white on a JPG is usually in fact a range of colors close to pure red or white.

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:kcmagicdata
ID: 18753897
Im sorry but there might be a bit of confusion here.
I dont want to do Transparency. I dont want the image to be "see through" like glass.
I want to be able to have a image preloaded such as a JPG or BMP and have a certain color that is a background in the picture not show up.

Here is an example of what i mean using the mentioned Transparentpicture.ocx in XP.

Here is what the actual image looks like

www.kaisergame.com/temp/100.bmp

and here is how it is suppose to look after the background of white has been removed.

http://www.kaisergame.com/Home/picture003.jpg

Not sure if those will come through as links?

My program has preloaded images that are from BMP and do not need to be stretched but do need to have the white background taken out. But a user also gets to load their own JPG files that will not need a transparent background but will need to be stretched to fit the size of the control. Because this is done in the same picturebox it has to have the ability to do both.






0
 

Author Comment

by:kcmagicdata
ID: 18762063
I managed to solve my own problem with a lot of searching and trying different code.

I found some excellent code that resizes the image in a Picturebox perfectly. Even when shrinking a JPG

        With Picture1
        .AutoRedraw = True
        .PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight, 0, 0, ScaleX(.Picture.Width, vbHimetric, vbTwips), ScaleY(.Picture.Height, vbHimetric, vbTwips)
        .Picture = .Image
        Set Picture1.Picture = .Image
        End With

I also found an open source control that does transparent images very well. So i modified the control to have a stretch property and compiled it. If anyone wants to try it or see how well it works here is a link

www.kaisergame.com/temp/Transpic.ocx

Although it does not have an Auto Size property. So stretching doesnt resize the image control. Only because my application has predefined image sizes and didnt need that feature.


0
 
LVL 1

Accepted Solution

by:
Vee_Mod earned 0 total points
ID: 19159157
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now