Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stretch and Transparent Picturebox

Posted on 2007-03-19
8
Medium Priority
?
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 

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

Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

705 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