Solved

Stretch and Transparent Picturebox

Posted on 2007-03-19
8
435 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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Server 2016 can't install roles 3 36
Picture size 4 37
VBA to find and replace multiline text from VBA modules 8 66
2008 R2 export VM includes VHD 1 9
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

821 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