graphics object probs(与2周前相同) [英] graphics object probs (same as 2 weeks ago)

查看:73
本文介绍了graphics object probs(与2周前相同)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回到星期六的工作;)


欢迎所有帮助(如果有其他方式这样做我不介意

,因为它的工作原理)


i必须在代码中组成一个图像。

我有一个背景图像(一个位图但我可以根据需要转换它)还有一个十字架的图像(有点像xp表格上的关闭按钮)

i必须在背景图像上将交叉放置在有限的nr次上

具体坐标

完成后我必须保存新图像w穿过sql db(这个
不应该是一个问题)


以下代码


当我尝试从位图获取图形时出现错误:

图形对象不能从具有索引像素的图像创建

格式。


tnx提前


eric


私人schGra作为图形


尝试

Dim s As System.Drawing.Image

s = System.Drawing.Image.FromFile(" F:\OvrAlles4.bmp")

schGra = Graphics.FromImage(s)''这给出了错误

Dim kr作为新位图(imgLijst.Images(0))

Dim t As Image

t = imgLijst.Images(0)

For i As整数= 0到100

如果kruisjes(i).Visible那么

schGra.DrawImage(t,(kruisjes(i).Left),

(kruisjes(i).Top))

''schGra.DrawImage()


结束如果

下一步

PictureBox1.Image = s

Catch ex As Exception

MessageBox.Show(ex.HelpLink& " " &安培; ex.Message& " button2 klik

"," fout",MessageBoxButtons.OK)

结束尝试

back at the saturday job ;)

all help is welcome ( if there is an other way of doing this i don''t mind as
long as it works)

i have to compose an image in code.
I have a background image (a bitmap but i can convert it if needed) and an
image of a cross (bit like the close button on an xp form)
i have to place the cross a limited nr of times on the background image at
specific coordinates
when this is done i have to save the new image w crosses in an sql db (this
should not be a prob)

code below

when i try to get the graphicsfrom the bitmap i get an error :
Graphics object cannot be created from an image that has an indexed pixel
format.

tnx in advance

eric

Private schGra As Graphics

Try
Dim s As System.Drawing.Image
s = System.Drawing.Image.FromFile("F:\OvrAlles4.bmp")
schGra = Graphics.FromImage(s) '' this gives the error
Dim kr As New Bitmap(imgLijst.Images(0))
Dim t As Image
t = imgLijst.Images(0)
For i As Integer = 0 To 100
If kruisjes(i).Visible Then
schGra.DrawImage(t, (kruisjes(i).Left),
(kruisjes(i).Top))
''schGra.DrawImage()

End If
Next
PictureBox1.Image = s
Catch ex As Exception
MessageBox.Show(ex.HelpLink & " " & ex.Message & " button2 klik
", "fout", MessageBoxButtons.OK)
End Try

推荐答案

嗨Eric,


今天我写的是你这周末不会来这里你是不是来这里。


这段代码我从我做过的那个程序中提取出来的,它不一样了,我确实改变了一些关于矩形的东西,但是你看到了这个怎么样?
去了用位图。在你的程序中我认为你缺少那个图层

的位图。


也许Herfried纠正了,因为在这个领域我是一个新手。 />

\\\

Dim fdlOpen As New OpenFileDialog

Dim origineleImage As Image

Dim nieuweImage As Image

fdlOpen.Filter ="所有图像格式(* .bmp; * .jpg; * .jpeg; * .gif; * .tif)|" &安培; _

" * .bmp; *。jpg; * .jpeg; * .gif; * .tif | Bitmaps

(* .bmp)| * .bmp | " &安培; _

" GIFs(* .gif)| * .gif | JPEGs(* .jpg)| * .jpg; * .jpeg | TIFs

(* .tif )| * .tif"

如果fdlOpen.ShowDialog()= DialogResult.OK那么

origineleImage = Image.FromFile(fdlOpen.FileName)

''之前只是你可以复制那个,而不是你不需要

写的

''它再一次我总是喜欢那个掩码。


Dim bmp As Bitmap = New Bitmap(origineleImage.Width,

origineleImage.Height)

Dim grBitmap As Graphics = Graphics.FromImage(bmp)

grBitmap.DrawImage(origineleImage,origineleImage.Width,

origineleImage.Height)

nieuweImage = bmp

grBitmap.Dispose()

结束如果

///
Hi Eric,

Did I just write today that you would not be here this weekend are you here.

This code I extracted from that program I did made, it is not the same and I
did change some things about the rectangle''s, but with that you see how that
goes with the bitmap. In your program I thought you are missing that layer
for the bitmap.

Maybe Herfried correct that because in this area I am very a newbie.

\\\
Dim fdlOpen As New OpenFileDialog
Dim origineleImage As Image
Dim nieuweImage As Image
fdlOpen.Filter = "All Image Formats (*.bmp;*.jpg;*.jpeg;*.gif;*.tif)|" & _
"*.bmp;*.jpg;*.jpeg;*.gif;*.tif|Bitmaps
(*.bmp)|*.bmp|" & _
"GIFs (*.gif)|*.gif|JPEGs (*.jpg)|*.jpg;*.jpeg|TIFs
(*.tif)|*.tif"
If fdlOpen.ShowDialog() = DialogResult.OK Then
origineleImage = Image.FromFile(fdlOpen.FileName)

''Before this is just that you could copy that, than would you not have to
write
'' it again I am always strugling with that mask.

Dim bmp As Bitmap = New Bitmap(origineleImage.Width,
origineleImage.Height)
Dim grBitmap As Graphics = Graphics.FromImage(bmp)
grBitmap.DrawImage(origineleImage, origineleImage.Width,
origineleImage.Height)
nieuweImage = bmp
grBitmap.Dispose()
End If
///


*" EricJ" < ER ****************** @ ThiSbitconsult.be> scripsit:
* "EricJ" <er******************@ThiSbitconsult.be> scripsit:
欢迎所有帮助(如果有其他方式这样做我不介意
,只要它有效)

我有用代码组成图像。
我有一个背景图像(一个位图,但我可以根据需要进行转换)和一个十字架的图像(像xp表格上的关闭按钮一样)
我必须在特定坐标的背景图像上放置有限n次的交叉点
当这个完成时我必须保存新的图像w十字架在sql db(这个
不应该是一个问题)

下面的代码

当我试图从位图获取图形时我得到一个错误:
图形对象不能从一个具有索引像素格式的图像。
all help is welcome ( if there is an other way of doing this i don''t mind as
long as it works)

i have to compose an image in code.
I have a background image (a bitmap but i can convert it if needed) and an
image of a cross (bit like the close button on an xp form)
i have to place the cross a limited nr of times on the background image at
specific coordinates
when this is done i have to save the new image w crosses in an sql db (this
should not be a prob)

code below

when i try to get the graphicsfrom the bitmap i get an error :
Graphics object cannot be created from an image that has an indexed pixel
format.




您必须使用非索引像素创建新的位图对象

格式,为它获取一个''Graphics''对象,并将索引的位图

绘制到此图像上。


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>



You will have to create a new bitmap object with non-indexed pixel
format, obtain a ''Graphics'' object for it and paint the indexed bitmap
onto this image.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


Hi Herfried,
我在Fergus的样品之后做了什么,也许那里很多东西要花很多钱(这不是弗格斯做的,而是我做的其他东西

来自文档)。


这是(你的)专业之一。


Cor
Hi Herfried,

Do us a favor and check my sample that I did send to Eric, this is a result
what I did made after that sample from Fergus, and maybe there is much to
much in it (this is not what Fergus did made but something else that I made
from the documentation).

And this is (one of ) your specialities.

Cor


这篇关于graphics object probs(与2周前相同)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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