473,765 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.c om
http://www.dotnetmonster.com/Uwe/For...b-net/200510/1
Nov 21 '05 #1
2 1677
Hi,

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

Ken
---------------------
"Tamer Abdalla via DotNetMonster.c om" <u12711@uwe> wrote in message
news:556062972e 726@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.c om
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles _ Button1.Click

ProgressBar1.Va lue = 0
ProgressBar1.St ep = 1
ProgressBar1.Ma ximum = 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(Environm ent.GetFolderPa th
_(Environment.S pecialFolder.De sktopDirectory) & "\images\test.b mp")

'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.FromIm age(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(bmp ToSplit, New Rectangle(0, 0, 8, 16), x, y, 8, 16,
GraphicsUnit.Pi xel)
x += 8
If x = 128 Then
x = 0
y += 16
End If

'save the newly created image

images(i).Save( Environment.Get FolderPath(Envi ronment.Special Folder.DesktopD i
rectory) & "\images\" & _ i & ".bmp", Imaging.ImageFo rmat.Bmp)
ProgressBar1.Pe rformStep()
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.FromIm age(bmpFromSpli tted)

For i As Integer = 0 To 255

'Now loop trough all the 256 files and put them at the original
location
g.DrawImage(Ima ge.FromFile(Env ironment.GetFol derPath
_(Environment.S pecialFolder.De sktopDirectory) & "\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("Splitti ng 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***@bellsout h.net> schreef in bericht
news:u0******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

http://www.windowsformsdatagridhelp....32-51bf-4e9d-a
f43-fa9d76e54f15
Ken
---------------------
"Tamer Abdalla via DotNetMonster.c om" <u12711@uwe> wrote in message
news:556062972e 726@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.c om
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
1346
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 should help me learn. My question is about IntPtr. Basically what is it, I know its a pointer but what is a pointer.(of course I know it points to something but how) . In my MenuControl I needed a graphics object in my OnPaint override.
1
1408
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: panel1_OnMouseDown. I have provided a snipet from the delegate: private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs mea) {
2
1022
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) myLine.DrawLine(System.Drawing.Pens.Red, Me.Left, (Me.Top + Me.Height) \ 2, Me.Left + Me.Width, (Me.Top + Me.Height) \ 2)
5
27167
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 e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 + yPos, AStringFormat) e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2, TheHeight1 + (390 + yPos))
14
2153
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 and holds everything a unit in my game is supposed to do. What are some some cures for this kind of large object or are they OK because they represent one thing. If not what are better ways to design objects that behave the same way. Would it be...
9
1936
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 stream Can anyone tell me the steps I need to perform and the classes/methods involved? You don't have to write out the whole program. Some basic ideas
2
3904
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 Application.Exit(); Alright well what would I put for the print preview and the print and Save and saveas and open and new? I can't find anything for these. I am new at this and I am sure I am not going in the correct order to learn this stuff but I...
63
3468
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, in this day and age, does the C standard have no abstract and portable method for dealing with directories? It doesn't seem like a particularly difficult problem. For instance, this int show_current_directory(struct DIRSTRUCT *current_directory);
4
3076
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 computing and graphics. R is designed with matrix manipulation in mind, and it's very easy to do regression and time series modeling, and to plot the results and test hypotheses. The kinds of functionality we rely on the most are standard and...
0
10164
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.