473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

About graphics.

Hello, everyone!

I DO need some help in order to understand how to create graphics in VB.NET.
I'm a little bit confused... I once knew a time when using Point & PSet was
almost the only way to make some interesting apps which could tranform images
(i.e. making saturation of colours "heavy", or gradually fade to grayscale,
or "erasing" a colour... and so on), while nowadays it seems quite impossible.
Now that I got .NET over VisualStudio I'm trying to figure out how to make a
program that is the equivalent of "Hello, world!" speakin' in graphical terms:
I need to split a B&W bitmap (W x H: 128 x 256 pixels) into 256 different
pieces of it (W x H: 8 x 16), while saving them into 256 different files.

HELP ME!
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200510/1
Nov 21 '05 #1
2 1657
Hi,

http://www.windowsformsdatagridhelp....3-fa9d76e54f15

Ken
---------------------
"Tamer Abdalla via DotNetMonster.com" <u12711@uwe> wrote in message
news:556062972e726@uwe...
Hello, everyone!

I DO need some help in order to understand how to create graphics in
VB.NET.
I'm a little bit confused... I once knew a time when using Point & PSet
was
almost the only way to make some interesting apps which could tranform
images
(i.e. making saturation of colours "heavy", or gradually fade to
grayscale,
or "erasing" a colour... and so on), while nowadays it seems quite
impossible.
Now that I got .NET over VisualStudio I'm trying to figure out how to make
a
program that is the equivalent of "Hello, world!" speakin' in graphical
terms:
I need to split a B&W bitmap (W x H: 128 x 256 pixels) into 256 different
pieces of it (W x H: 8 x 16), while saving them into 256 different files.

HELP ME!
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200510/1

Nov 21 '05 #2
Hi,

to add to what Ken posted I created an example with explanation for you.
Place a button and two 128 x 256 picturboxes and a progressbar on a form.
Name the pictureboxes picOrg and picSplit. Create a directory images on your
desktop and place the file to split in it.

Next paste in the following code, for the explanation see the comments in
the code.

Hth Greetz Peter

'at the top of your form you need to import system.drawing
Imports System.Drawing

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _ Button1.Click

ProgressBar1.Value = 0
ProgressBar1.Step = 1
ProgressBar1.Maximum = 255
'Load the bitmap/image to split from it's location
'in my case a directory called images on the desktop
Dim bmpToSplit As New Bitmap(Environment.GetFolderPath
_(Environment.SpecialFolder.DesktopDirectory) & "\images\test.bmp")

'Create a new bitmap to check if the splitted parts are the same as the
original after the splitting
Dim bmpFromSplitted As New Bitmap(128, 256)

'create a graphics object to do the drawing
Dim g As Graphics

'create a 256 items containing image array (0-255)
Dim images(255) As Bitmap
Dim x, y As Integer

For i As Integer = 0 To 255
'Initialize each array item
images(i) = New Bitmap(8, 16)

'assign the image to the graphics object so it knows what
'it needs to draw on
g = Graphics.FromImage(images(i))

'get the correct part of the original image and draw it onto one of our
255
'small images
'If you'd translate this line of code into normal language it would be
something like
'take a 8 x 16 part of the original at location x,y and draw it onto or
new image beginning at
'location 0 , 0 and draw it with a width of 8 and height of 16
g.DrawImage(bmpToSplit, New Rectangle(0, 0, 8, 16), x, y, 8, 16,
GraphicsUnit.Pixel)
x += 8
If x = 128 Then
x = 0
y += 16
End If

'save the newly created image

images(i).Save(Environment.GetFolderPath(Environme nt.SpecialFolder.DesktopDi
rectory) & "\images\" & _ i & ".bmp", Imaging.ImageFormat.Bmp)
ProgressBar1.PerformStep()
Next

'reset or x and y counter
x = 0
y = 0

'Now we're going to recreat the original image from all 256
'small images

'First assign the bmpFromSplitted bitmap to the graphics object so it knows
what
'it needs to draw on
g = Graphics.FromImage(bmpFromSplitted)

For i As Integer = 0 To 255

'Now loop trough all the 256 files and put them at the original
location
g.DrawImage(Image.FromFile(Environment.GetFolderPa th
_(Environment.SpecialFolder.DesktopDirectory) & "\images\" & i & ".bmp"), x,
y)
x += 8
If x = 128 Then
x = 0
y += 16
End If
Next

'dispose the graphics object
g.Dispose()

'Load the original image and the image created from all small files
'in the pictureboxes
picOrg.Image = bmpToSplit
picSplit.Image = bmpFromSplitted
MsgBox("Splitting complete")
End Sub

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:u0**************@TK2MSFTNGP15.phx.gbl...
Hi,

http://www.windowsformsdatagridhelp....32-51bf-4e9d-a
f43-fa9d76e54f15
Ken
---------------------
"Tamer Abdalla via DotNetMonster.com" <u12711@uwe> wrote in message
news:556062972e726@uwe...
Hello, everyone!

I DO need some help in order to understand how to create graphics in
VB.NET.
I'm a little bit confused... I once knew a time when using Point & PSet
was
almost the only way to make some interesting apps which could tranform
images
(i.e. making saturation of colours "heavy", or gradually fade to
grayscale,
or "erasing" a colour... and so on), while nowadays it seems quite
impossible.
Now that I got .NET over VisualStudio I'm trying to figure out how to make a
program that is the equivalent of "Hello, world!" speakin' in graphical
terms:
I need to split a B&W bitmap (W x H: 128 x 256 pixels) into 256 different pieces of it (W x H: 8 x 16), while saving them into 256 different files.
HELP ME!
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200510/1


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ron Vecchi | last post by:
I am creating my own MainMenu control similar to VS.Net. (yes I know theirs some out their). I have predominatly been a web developer for about 5 years and am playing with Windows forms. So this...
1
by: Beringer | last post by:
Hello, I have a panel that I have used as a control to be drawn on. I want to handle say OnMouseHover or OnMouseDown events. To do this I used Visual C# and it created a delegate called:...
2
by: MenuChen | last post by:
This Code doesn't work ************************ Protected Overrides Sub WndProc(ByRef m As Message) MyBase.WndProc(m) Dim myLine As Graphics = System.Drawing.Graphics.FromHwnd(Me.Handle)...
5
by: Charles A. Lackman | last post by:
Hello, I have created a complete PrintDocument and need to create an image from it. How is this done? e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality...
14
by: JoeC | last post by:
I have been writing games and I also read about good programming techniques. I tend to create large objects that do lots of things. A good example I have is a unit object. The object controls...
9
by: poifull | last post by:
Hi All, I have the following task: 1. create an image object in memory (a rectangle with nothing on it) 2. write some text on the rectangle 3. rotate the image 90 degree 4. save the image to a...
2
by: Kool-Aide | last post by:
Alright, here goes...When I put a menu strip on the windows form I can double click the exit button to go to the source page and it takes me to the on click exit blah blah blah and you would put...
63
by: David Mathog | last post by:
There have been a series of questions about directory operations, all of which have been answered with "there is no portable way to do this". This raises the perfectly reasonable question, why,...
4
by: Talbot Katz | last post by:
Greetings Pythoners! I hope you'll indulge an ignorant outsider. I work at a financial software firm, and the tool I currently use for my research is R, a software environment for statistical...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.