图像和节省时间/空间 [英] images and saving time/space

查看:63
本文介绍了图像和节省时间/空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好


我有几张图片会在同一个地方的不同

表格上反复使用,我决定创建一个控件来保存

开发空间/时间,我创建了一个继承面板的控件

并添加了三个面板控件来托管3个背景图像(一个到

左边的另一个和一个填补空白)现在用这个

控制文本框将被添加到这些控件上

预定的形式然而,当你到达这个阶段时,他们似乎消失了

当我把它们移到前面时他们来到了前面但是有继承的b $ b主要形式的背景颜色,而不是我的面板的背景颜色

控制任何有关如何绕过这个的想法。

谢谢Mike。

推荐答案

嗨迈克尔,


我最近用新的免费编程完成了这项工作ram(包括来源)

WTR - Web The Ripper 2.在给你

链接之前,我会先强调一下我的所作所为。


*将图像作为资源嵌入,但是如果你想要它将alpha

混合到背景颜色中,则使用PNG文件。我选择了15%alpha。

*在基本表单中的面板控件的Paint事件中,执行

跟随,


~~~


静态pBmpBackdrop As Bitmap = getBackdrop(panStep.Width,panStep.Height,

panStep.BackColor)

调用e.Graphics.DrawImageUnscaled(pBmpBackdrop,0,0)

~~~


私函数getBackdrop(ByVal iWidth As Integer ,ByVal iHeight As

Integer,ByVal iBackColour As Color)As Bitmap

Dim pBmpAlpha As New Bitmap(iWidth,iHeight)

Dim pImgBack As Image =

getImageFromResource(" fullnamespace.backdrop.png")

Dim pGraAlpha As Graphics = Graphics.FromImage(pBmpAlpha)

致电pGraAlpha .Clear(iBackColour)

调用pGraAlpha.DrawImage(pImgBack,New Rectangle(CInt((pBmpAlpha.Width /

2) - (pImgBack.Width / 2)), CInt((pBmpAlpha.Height / 2) - (pImgBack.Height /

2)),pImgBack.Width,pImgBack.Height),0,0 ,pImgBack.Width,

pImgBack.Height,GraphicsUnit.Pixel)

调用pGraAlpha.Dispose()

返回(pBmpAlpha)

结束函数


公共共享函数getImageFromResource(ByVal iKey As String)as Image

Dim pAssAssembly As [Assembly] = [Assembly]。 GetExecutingAssembly

Dim pStmInput As Stream = pAssAssembly.GetManifestResourceStream(iKey)

Dim pImgImage As Image = Image.FromStream(pStmInput,False)

Call pStmInput.Close()

返回(pImgImage)

结束功能


~~~


然后编译你的应用程序并运行它。你应该看到一张图片

画在面板的中间。你还想做的一件事是

制作任何标签,复选框和单选按钮的背面颜色

透明。但是*不要*使用网页透明,这对我来说有奇怪的效果

。相反,您可以在加载它时从派生类

(将它放在基类中)调用以下方法。


受保护的子makeControlsTransparent()

Dim pCtlCurControl作为控件

每个pCtlCurControl在panStep.Controls

If(TypeOf(pCtlCurControl)是标签)然后

CType(pCtlCurControl,Label).BackColor =

System.Drawing.Color.Transparent

ElseIf(TypeOf(pCtlCurControl)是CheckBox)然后

CType(pCtlCurControl,CheckBox).BackColor =

System.Drawing.Color.Transparent

ElseIf(TypeOf(pCtlCurControl)是RadioButton)然后

CType(pCtlCurControl,RadioButton).BackColor =

System.Drawing.Color.Transparent

结束如果

下一页

结束子


对于一个完整的工作应用程序,例如代码非常易读,

转到我的主页

< a rel =nofollowhref =http://www.members.lycos.co.uk/nickpatemanp wp /target =_ blank> http://www.members.lycos.co.uk/nickpatemanpwp/

^点击我自己的软件 > WTR - Web The Ripper 2。


Nick。


Michael Turner <音响***** @ m-turner.co.uk>在消息中写道

新闻:e7 ************** @ tk2msftngp13.phx.gbl ...
Hi Michael,

I''ve done this recently with my new free program (including source)
WTR - Web The Ripper 2. I''ll highlight what I done before giving you the
link.

*Embed the image as a resource but use a PNG file if you want it alpha
blended into the background colour. I chose 15% alpha.
*In the Paint event of the panel control in the base form, do the
following,

~~~

Static pBmpBackdrop As Bitmap = getBackdrop(panStep.Width, panStep.Height,
panStep.BackColor)
Call e.Graphics.DrawImageUnscaled(pBmpBackdrop, 0, 0)

~~~

Private Function getBackdrop(ByVal iWidth As Integer, ByVal iHeight As
Integer, ByVal iBackColour As Color) As Bitmap
Dim pBmpAlpha As New Bitmap(iWidth, iHeight)
Dim pImgBack As Image =
getImageFromResource("fullnamespace.backdrop.png")
Dim pGraAlpha As Graphics = Graphics.FromImage(pBmpAlpha)
Call pGraAlpha.Clear(iBackColour)
Call pGraAlpha.DrawImage(pImgBack, New Rectangle(CInt((pBmpAlpha.Width /
2) - (pImgBack.Width / 2)), CInt((pBmpAlpha.Height / 2) - (pImgBack.Height /
2)), pImgBack.Width, pImgBack.Height), 0, 0, pImgBack.Width,
pImgBack.Height, GraphicsUnit.Pixel)
Call pGraAlpha.Dispose()
Return (pBmpAlpha)
End Function

Public Shared Function getImageFromResource(ByVal iKey As String) As Image
Dim pAssAssembly As [Assembly] = [Assembly].GetExecutingAssembly
Dim pStmInput As Stream = pAssAssembly.GetManifestResourceStream(iKey)
Dim pImgImage As Image = Image.FromStream(pStmInput, False)
Call pStmInput.Close()
Return (pImgImage)
End Function

~~~

Then compile your application and run it. You should see a picture
painted into the middle of the panel. One thing you will also want to do is
make the back colour of any labels, check boxes and radio buttons
Transparent. But *dont* use the web transparent, this had strange effects
for me. Instead you can call the following method from the derived class
(put it in the base class) upon loading it.

Protected Sub makeControlsTransparent()
Dim pCtlCurControl As Control
For Each pCtlCurControl In panStep.Controls
If (TypeOf (pCtlCurControl) Is Label) Then
CType(pCtlCurControl, Label).BackColor =
System.Drawing.Color.Transparent
ElseIf (TypeOf (pCtlCurControl) Is CheckBox) Then
CType(pCtlCurControl, CheckBox).BackColor =
System.Drawing.Color.Transparent
ElseIf (TypeOf (pCtlCurControl) Is RadioButton) Then
CType(pCtlCurControl, RadioButton).BackColor =
System.Drawing.Color.Transparent
End If
Next
End Sub

For a full working application as an example with very readable code,
goto my home page

http://www.members.lycos.co.uk/nickpatemanpwp/
^Click "My Own Software" > "WTR - Web The Ripper 2".

Nick.

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
嗨大家
我有几张图片会在同一个地方以不同的形式一遍又一遍地使用,我决定创建一个控件来保存开发中的空间/时间,我有创建一个继承
面板的控件,并添加了三个面板控件,其中包含3个背景图像(
一个在左边,另一个在右边,一个用于填补空白)现在用
这个控制文本框一旦被添加到预期的形式就会被放置在这些控件上但是当你到达这个阶段时,当我将它们移到前面时它们似乎消失了它们来自的转发<但是继承了主要形式的背景颜色而不是我的控制面板中有关如何绕过这个的任何想法。

谢谢Mike。
Hi Guys

I have several images that will be used over and over again on different
forms in the same place, I have decided to create a control to save
space/time in development, I have create a control which inherits the
panel and added three panel control which host the 3 background images (
one to the left the other to the right and one to fill the gap) now with
this control textboxes will be placed on these controls once they are
added to the intended form however when you get to this stage they seem to
dissapear when I move them to the front the repear they come to the from
but have inherited the background colour of the main form and not of my
panels in my control any ideas on how to get round this.
Thanks Mike.



嗨迈克尔,


我''我最近使用我的新免费程序(包括来源)完成了这项工作

WTR - Web The Ripper 2.我会在给你

链接之前突出我的所作所为。


*将图像作为资源嵌入,但是如果你想要它将alpha

混合到背景颜色中,则使用PNG文件。我选择了15%alpha。

*在基本表单中的面板控件的Paint事件中,执行

跟随,


~~~


静态pBmpBackdrop As Bitmap = getBackdrop(panStep.Width,panStep.Height,

panStep.BackColor)

调用e.Graphics.DrawImageUnscaled(pBmpBackdrop,0,0)

~~~


私函数getBackdrop(ByVal iWidth As Integer ,ByVal iHeight As

Integer,ByVal iBackColour As Color)As Bitmap

Dim pBmpAlpha As New Bitmap(iWidth,iHeight)

Dim pImgBack As Image =

getImageFromResource(" fullnamespace.backdrop.png")

Dim pGraAlpha As Graphics = Graphics.FromImage(pBmpAlpha)

致电pGraAlpha .Clear(iBackColour)

调用pGraAlpha.DrawImage(pImgBack,New Rectangle(CInt((pBmpAlpha.Width /

2) - (pImgBack.Width / 2)), CInt((pBmpAlpha.Height / 2) - (pImgBack.Height /

2)),pImgBack.Width,pImgBack.Height),0,0 ,pImgBack.Width,

pImgBack.Height,GraphicsUnit.Pixel)

调用pGraAlpha.Dispose()

返回(pBmpAlpha)

结束函数


公共共享函数getImageFromResource(ByVal iKey As String)as Image

Dim pAssAssembly As [Assembly] = [Assembly]。 GetExecutingAssembly

Dim pStmInput As Stream = pAssAssembly.GetManifestResourceStream(iKey)

Dim pImgImage As Image = Image.FromStream(pStmInput,False)

Call pStmInput.Close()

返回(pImgImage)

结束功能


~~~


然后编译你的应用程序并运行它。你应该看到一张图片

画在面板的中间。你还想做的一件事是

制作任何标签,复选框和单选按钮的背面颜色

透明。但是*不要*使用网页透明,这对我来说有奇怪的效果

。相反,您可以在加载它时从派生类

(将它放在基类中)调用以下方法。


受保护的子makeControlsTransparent()

Dim pCtlCurControl作为控件

每个pCtlCurControl在panStep.Controls

If(TypeOf(pCtlCurControl)是标签)然后

CType(pCtlCurControl,Label).BackColor =

System.Drawing.Color.Transparent

ElseIf(TypeOf(pCtlCurControl)是CheckBox)然后

CType(pCtlCurControl,CheckBox).BackColor =

System.Drawing.Color.Transparent

ElseIf(TypeOf(pCtlCurControl)是RadioButton)然后

CType(pCtlCurControl,RadioButton).BackColor =

System.Drawing.Color.Transparent

结束如果

下一页

结束子


对于一个完整的工作应用程序,例如代码非常易读,

转到我的主页

< a rel =nofollowhref =http://www.members.lycos.co.uk/nickpatemanp wp /target =_ blank> http://www.members.lycos.co.uk/nickpatemanpwp/

^点击我自己的软件 > WTR - Web The Ripper 2。


Nick。


Michael Turner <音响***** @ m-turner.co.uk>在消息中写道

新闻:e7 ************** @ tk2msftngp13.phx.gbl ...
Hi Michael,

I''ve done this recently with my new free program (including source)
WTR - Web The Ripper 2. I''ll highlight what I done before giving you the
link.

*Embed the image as a resource but use a PNG file if you want it alpha
blended into the background colour. I chose 15% alpha.
*In the Paint event of the panel control in the base form, do the
following,

~~~

Static pBmpBackdrop As Bitmap = getBackdrop(panStep.Width, panStep.Height,
panStep.BackColor)
Call e.Graphics.DrawImageUnscaled(pBmpBackdrop, 0, 0)

~~~

Private Function getBackdrop(ByVal iWidth As Integer, ByVal iHeight As
Integer, ByVal iBackColour As Color) As Bitmap
Dim pBmpAlpha As New Bitmap(iWidth, iHeight)
Dim pImgBack As Image =
getImageFromResource("fullnamespace.backdrop.png")
Dim pGraAlpha As Graphics = Graphics.FromImage(pBmpAlpha)
Call pGraAlpha.Clear(iBackColour)
Call pGraAlpha.DrawImage(pImgBack, New Rectangle(CInt((pBmpAlpha.Width /
2) - (pImgBack.Width / 2)), CInt((pBmpAlpha.Height / 2) - (pImgBack.Height /
2)), pImgBack.Width, pImgBack.Height), 0, 0, pImgBack.Width,
pImgBack.Height, GraphicsUnit.Pixel)
Call pGraAlpha.Dispose()
Return (pBmpAlpha)
End Function

Public Shared Function getImageFromResource(ByVal iKey As String) As Image
Dim pAssAssembly As [Assembly] = [Assembly].GetExecutingAssembly
Dim pStmInput As Stream = pAssAssembly.GetManifestResourceStream(iKey)
Dim pImgImage As Image = Image.FromStream(pStmInput, False)
Call pStmInput.Close()
Return (pImgImage)
End Function

~~~

Then compile your application and run it. You should see a picture
painted into the middle of the panel. One thing you will also want to do is
make the back colour of any labels, check boxes and radio buttons
Transparent. But *dont* use the web transparent, this had strange effects
for me. Instead you can call the following method from the derived class
(put it in the base class) upon loading it.

Protected Sub makeControlsTransparent()
Dim pCtlCurControl As Control
For Each pCtlCurControl In panStep.Controls
If (TypeOf (pCtlCurControl) Is Label) Then
CType(pCtlCurControl, Label).BackColor =
System.Drawing.Color.Transparent
ElseIf (TypeOf (pCtlCurControl) Is CheckBox) Then
CType(pCtlCurControl, CheckBox).BackColor =
System.Drawing.Color.Transparent
ElseIf (TypeOf (pCtlCurControl) Is RadioButton) Then
CType(pCtlCurControl, RadioButton).BackColor =
System.Drawing.Color.Transparent
End If
Next
End Sub

For a full working application as an example with very readable code,
goto my home page

http://www.members.lycos.co.uk/nickpatemanpwp/
^Click "My Own Software" > "WTR - Web The Ripper 2".

Nick.

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
嗨大家
我有几张图片会在同一个地方以不同的形式一遍又一遍地使用,我决定创建一个控件来保存开发中的空间/时间,我有创建一个继承
面板的控件,并添加了三个面板控件,其中包含3个背景图像(
一个在左边,另一个在右边,一个用于填补空白)现在用
这个控制文本框一旦被添加到预期的形式就会被放置在这些控件上但是当你到达这个阶段时,当我将它们移到前面时它们似乎消失了它们来自的转发<但是继承了主要形式的背景颜色而不是我的控制面板中有关如何绕过这个的任何想法。

谢谢Mike。
Hi Guys

I have several images that will be used over and over again on different
forms in the same place, I have decided to create a control to save
space/time in development, I have create a control which inherits the
panel and added three panel control which host the 3 background images (
one to the left the other to the right and one to fill the gap) now with
this control textboxes will be placed on these controls once they are
added to the intended form however when you get to this stage they seem to
dissapear when I move them to the front the repear they come to the from
but have inherited the background colour of the main form and not of my
panels in my control any ideas on how to get round this.
Thanks Mike.



干杯,经过一段时间的游戏后获得我想要的结果我终于得到了

我之后的确如此


再次感谢


迈克。

" Nak" < a@a.com>在消息中写道

新闻:OO ************** @ TK2MSFTNGP09.phx.gbl ...
Cheers, after a bit of playing to get the result I wanted I have finally got
exactly what I was after

Thanks again

Mike.
"Nak" <a@a.com> wrote in message
news:OO**************@TK2MSFTNGP09.phx.gbl...
嗨迈克尔,

我最近用我的新免费程序(包括源代码)完成了这个工作
WTR - Web The Ripper 2.我会在给你
链接之前强调我的所作所为。

*将图像作为资源嵌入,但如果您希望将图像混合到背景颜色中,请使用PNG文件。我选择了15%的alpha。
*在基本形式的面板控件的Paint事件中,执行
以下,

~~~
静态pBmpBackdrop As Bitmap = getBackdrop(panStep.Width,panStep.Height,
panStep.BackColor)
调用e.Graphics.DrawImageUnscaled(pBmpBackdrop,0,0)
〜/〜 〜/

私函数getBackdrop(ByVal iWidth为整数,ByVal iHeight为
整数,ByVal iBackColour为颜色)作为位图
Dim pBmpAlpha为新位图(iWidth,iHeight)
Dim pImgBack As Image =
getImageFromResource(" fullnamespace.backdrop.png")
Dim pGraAlpha As Graphics = Graphics.FromImage(pBmpAlpha)
调用pGraAlpha.Clear(iBackColour)
调用pGraAlpha.DrawImage(pImgBack,新矩形(CInt((pBmpAlpha.Width
/ 2) - (pImgBack.Width / 2)),CInt((pBmpAlpha.Height / 2) -
(pImgBack.Height / 2)),pImgBack.Width,pImgBack.Height),0,0,
pImgBack.Width,pImgBack.Height,GraphicsUnit.Pixel)
C所有pGraAlpha.Dispose()
返回(pBmpAlpha)
结束函数

公共共享函数getImageFromResource(ByVal iKey as String)as Image
Dim pAssAssembly As [Assembly] = [Assembly] .GetExecutingAssembly
Dim pStmInput As Stream = pAssAssembly.GetManifestResourceStream(iKey)
Dim pImgImage As Image = Image.FromStream(pStmInput,False)
调用pStmInput.Close()结束功能

~~~
然后编译你的应用程序并运行它。你应该看到一张画在画面中间的画面。你还想做的一件事就是制作任何标签的背面颜色,复选框和单选按钮
透明。但*不要*使用网页透明,这对我来说有奇怪的效果。相反,你可以在加载它时从派生类中调用以下方法
(把它放在基类中)。

受保护的子makeControlsTransparent()
昏暗的pCtlCurControl作为控件
对于每个pCtlCurControl在panStep.Controls中
If(TypeOf(pCtlCurControl)是标签)然后
CType(pCtlCurControl,Label).BackColor =
System.Drawing.Color.Transparent
ElseIf(TypeOf(pCtlCurControl)是CheckBox)然后
CType(pCtlCurControl,CheckBox).BackColor =
System.Drawing.Color.Transparent
ElseIf(TypeOf(pCtlCurControl)是RadioButton)然后
CType(pCtlCurControl,RadioButton).BackColor =
System.Drawing.Color.Transparent
结束如果
下一页
结束子

完整的工作应用程序作为一个例子,具有非常易读的代码,
转到我的主页

http://www.members.lycos.co.uk/nickpatemanpwp/
^点击我自己的软件 > WTR - Web The Ripper 2。

Nick。

Michael Turner <音响***** @ m-turner.co.uk>在消息中写道
新闻:e7 ************** @ tk2msftngp13.phx.gbl ...
Hi Michael,

I''ve done this recently with my new free program (including source)
WTR - Web The Ripper 2. I''ll highlight what I done before giving you the
link.

*Embed the image as a resource but use a PNG file if you want it alpha
blended into the background colour. I chose 15% alpha.
*In the Paint event of the panel control in the base form, do the
following,

~~~

Static pBmpBackdrop As Bitmap = getBackdrop(panStep.Width, panStep.Height,
panStep.BackColor)
Call e.Graphics.DrawImageUnscaled(pBmpBackdrop, 0, 0)

~~~

Private Function getBackdrop(ByVal iWidth As Integer, ByVal iHeight As
Integer, ByVal iBackColour As Color) As Bitmap
Dim pBmpAlpha As New Bitmap(iWidth, iHeight)
Dim pImgBack As Image =
getImageFromResource("fullnamespace.backdrop.png")
Dim pGraAlpha As Graphics = Graphics.FromImage(pBmpAlpha)
Call pGraAlpha.Clear(iBackColour)
Call pGraAlpha.DrawImage(pImgBack, New Rectangle(CInt((pBmpAlpha.Width
/ 2) - (pImgBack.Width / 2)), CInt((pBmpAlpha.Height / 2) -
(pImgBack.Height / 2)), pImgBack.Width, pImgBack.Height), 0, 0,
pImgBack.Width, pImgBack.Height, GraphicsUnit.Pixel)
Call pGraAlpha.Dispose()
Return (pBmpAlpha)
End Function

Public Shared Function getImageFromResource(ByVal iKey As String) As Image
Dim pAssAssembly As [Assembly] = [Assembly].GetExecutingAssembly
Dim pStmInput As Stream = pAssAssembly.GetManifestResourceStream(iKey)
Dim pImgImage As Image = Image.FromStream(pStmInput, False)
Call pStmInput.Close()
Return (pImgImage)
End Function

~~~

Then compile your application and run it. You should see a picture
painted into the middle of the panel. One thing you will also want to do
is make the back colour of any labels, check boxes and radio buttons
Transparent. But *dont* use the web transparent, this had strange effects
for me. Instead you can call the following method from the derived class
(put it in the base class) upon loading it.

Protected Sub makeControlsTransparent()
Dim pCtlCurControl As Control
For Each pCtlCurControl In panStep.Controls
If (TypeOf (pCtlCurControl) Is Label) Then
CType(pCtlCurControl, Label).BackColor =
System.Drawing.Color.Transparent
ElseIf (TypeOf (pCtlCurControl) Is CheckBox) Then
CType(pCtlCurControl, CheckBox).BackColor =
System.Drawing.Color.Transparent
ElseIf (TypeOf (pCtlCurControl) Is RadioButton) Then
CType(pCtlCurControl, RadioButton).BackColor =
System.Drawing.Color.Transparent
End If
Next
End Sub

For a full working application as an example with very readable code,
goto my home page

http://www.members.lycos.co.uk/nickpatemanpwp/
^Click "My Own Software" > "WTR - Web The Ripper 2".

Nick.

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
大家好
我有几张图片会在同一个地方不同的
表格上反复使用,我决定创建一个控件来保存开发中的空间/时间,我已经创建了一个控件,继承
面板并添加了三个面板控件,其中包含3个背景图像
(一个在左边,另一个在右边,一个用于填补空白)现在
这个控件文本框将是一旦它们被添加到预期的形式,就放在这些控件上但是当你到达这个阶段时,当我将它们移到前面时它们似乎消失了它们来自的转发它们来自但是继承了主要表单的背景颜色,而不是我控制的面板中的任何想法如何绕过这个。

谢谢Mike。
Hi Guys

I have several images that will be used over and over again on different
forms in the same place, I have decided to create a control to save
space/time in development, I have create a control which inherits the
panel and added three panel control which host the 3 background images
( one to the left the other to the right and one to fill the gap) now
with this control textboxes will be placed on these controls once they
are added to the intended form however when you get to this stage they
seem to dissapear when I move them to the front the repear they come to
the from but have inherited the background colour of the main form and
not of my panels in my control any ideas on how to get round this.
Thanks Mike.







这篇关于图像和节省时间/空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆