473,408 Members | 2,417 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,408 software developers and data experts.

how to use GDI+ to color pixels from array

Greetings,

I am attempting to develop an application that will color the pixels
in a PictureBox based on the x and y coordinates for individual pixels
in an array. I would like to load the values into the array from a
database. Does this sound feasible? I'm new to CDI+ programming. I
thougnt he SetPixel method would work best but i'm not sure how to
proceed. Can I grab the values right from the database into the
PictureBox?

Any help is appreciated.

Daryl
Nov 20 '05 #1
2 1856
"djharrison" <da************@netscape.net> wrote in message
news:75**************************@posting.google.c om...
I am attempting to develop an application that will color the pixels
in a PictureBox based on the x and y coordinates for individual pixels
in an array. I would like to load the values into the array from a
database. Does this sound feasible? I'm new to CDI+ programming. I
thougnt he SetPixel method would work best but i'm not sure how to
proceed. Can I grab the values right from the database into the
PictureBox?


The best way to do that would be to load the values from the database
into a new Bitmap object, then assign that Bitmap to the PictureBox's Image
property:

Dim bmp As Bitmap = New Bitmap(100, 100)

For x As Integer = 0 to xxx
For y As Integer = 0 to yyy
Dim currentColor As Color
currentColor = GetColorFromDatabase(x, y)
bmp.SetPixel(x, y, currentColor)
Next y
Next x

PictureBox1.Image = bmp

But really, why not just store the bitmap files themselves in the
database (or even just as files)? That would greatly speed things up, not
to mention saving tons of space in the database and drastically simplifying
queries.

Jeremy

Nov 20 '05 #2
* da************@netscape.net (djharrison) scripsit:
I am attempting to develop an application that will color the pixels
in a PictureBox based on the x and y coordinates for individual pixels
in an array. I would like to load the values into the array from a
database. Does this sound feasible? I'm new to CDI+ programming. I
thougnt he SetPixel method would work best but i'm not sure how to
proceed. Can I grab the values right from the database into the
PictureBox?


Write the byte array containing the whole bitmap file into a
'MemoryStream', then create a new 'Bitmap' object from the data (see
overloaded versions of the 'Bitmap' constructur). Then you can use the
bitmap's 'GetPixel' and 'SetPixel' methods.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

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

Similar topics

1
by: DrDevious | last post by:
Maybe I am doing something wrong but has anyone else here noticed a difference in the positioning of text between the Graphics.DrawString method and the Win32 GDI DrawText function? My text is...
20
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic...
12
by: Charles Law | last post by:
If I draw a rectangle, 6 inches by 2 inches, on a user control with a PageUnit of Inches, I get a rectangle of 7 by 2.2 inches. Is this what people would expect? I would have hoped that it was at...
1
by: Paul E Collins | last post by:
I'm writing a fairly simple two-player puzzle game. I have a background image in a PNG file (44 KB, 160 x 320 pixels) which I load into an Image object ... imgCachedBackground =...
6
by: James dean | last post by:
I want a good site that will show clearly how much more functionality GDI+ has. I cannot seem to find anything other than sites that list "some" of the new functionality that GDI+ offers. A...
3
by: Nathan Sokalski | last post by:
I am using GDI+ to generate buttons in my application. Because I want the left and right edges of the buttons to be a certain number of pixels from the start and end of the text, I need to know (or...
0
by: Rotsey | last post by:
Hi, I have a jpg that i am using asa template using GDI to draw on. I am using paint to look at the jpg and using pixels to determine where I want to draw to with GDI. I changed the ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
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...

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.