I need to use the bitmap.getpixel method to work on the pixel level of
an image. But GetPixel will not work with Indexed images. The images
that i work with are black & white text scans.
I create the bitmap object like this:
Dim b As Bitmap = Bitmap.FromFile ("c:\scan.ti f")
But I want to convert this file to PixelFormat.For mat24bppRgb (or
something NOT indexed)
PixelFormat.For mat24bppRgb is Read Only, so i can't simply do:
b.pixelFormat = PixelFormat.For mat24bppRgb
Bitmap has an overload that allows the Pixelformat to be specified, but
the overload cannot accept a file name for my tiff, just a width and
height. If I use that overload, my bitmap object ends up blank. I
need it to hold image data.
I'm totally stumped. Can anyone help?
Thanks!
John 3 37651
You must create a new bitmap of the same size as the indexed one and then
draw the indexed bitmap to the new bitmap. This will convert all the colours
to 32 bit and enable you to draw on the bitmap.
Bitmap bm=new Bitmap(org.Widt h, org.Height <,optional pixel format>);
bm.SetResolutio n(org.Horizonta lResolution, org.VerticalRes olution);
Graphics g=Graphics.From Image(bm);
g.DrawImage(org ,0,0);
//continue to draw on g here to add text or graphics.
g.Dispose();
bm.Save(......) ;
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"johnb41" <or****@informa tik.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . I need to use the bitmap.getpixel method to work on the pixel level of an image. But GetPixel will not work with Indexed images. The images that i work with are black & white text scans.
I create the bitmap object like this: Dim b As Bitmap = Bitmap.FromFile ("c:\scan.ti f")
But I want to convert this file to PixelFormat.For mat24bppRgb (or something NOT indexed)
PixelFormat.For mat24bppRgb is Read Only, so i can't simply do: b.pixelFormat = PixelFormat.For mat24bppRgb
Bitmap has an overload that allows the Pixelformat to be specified, but the overload cannot accept a file name for my tiff, just a width and height. If I use that overload, my bitmap object ends up blank. I need it to hold image data.
I'm totally stumped. Can anyone help?
Thanks! John
Sorry, that sample code was in C#. in VB...
Dim bm as new Bitmap(org.Widt h, org.Height <,optional pixel format>)
bm.SetResolutio n(org.Horizonta lResolution, org.VerticalRes olution)
Dim g as Graphics = Graphics.FromIm age(bm)
g.DrawImage(org ,0,0)
'continue to draw on g here to add text or graphics.
g.Dispose()
bm.Save(......)
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"johnb41" <or****@informa tik.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . I need to use the bitmap.getpixel method to work on the pixel level of an image. But GetPixel will not work with Indexed images. The images that i work with are black & white text scans.
I create the bitmap object like this: Dim b As Bitmap = Bitmap.FromFile ("c:\scan.ti f")
But I want to convert this file to PixelFormat.For mat24bppRgb (or something NOT indexed)
PixelFormat.For mat24bppRgb is Read Only, so i can't simply do: b.pixelFormat = PixelFormat.For mat24bppRgb
Bitmap has an overload that allows the Pixelformat to be specified, but the overload cannot accept a file name for my tiff, just a width and height. If I use that overload, my bitmap object ends up blank. I need it to hold image data.
I'm totally stumped. Can anyone help?
Thanks! John
Bob,
Thanks, that helped alot! By the way, thanks for your web site. I've
learned alot from it the past couple weeks! :)
John
*** Sent via Developersdex http://www.developersdex.com *** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Anthony Liu |
last post by:
I want to use the set function like
mylist =
myset = set (mylist)
But I don't know what to import, I tried sys, sets,
they don't work.
What's the easy way to find out the module that
contains a particular function?
|
by: Skip Montanaro |
last post by:
I use sets a lot in my Python 2.3 code at work and have been using this
hideous import to make the future move to 2.4's set type transparent:
try:
x = set
except NameError:
from sets import Set as set
else:
del x
|
by: J. Muenchbourg |
last post by:
The following line in part of my asp-sql block:
Set rs = Server.CreateObject("ADODB.Recordset")
creates an application error: "Set" assignment statements are no longer
supported
(in this particular block):
<%
Dim rs, strSQLd
|
by: William Payne |
last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set
(with set I mean they equal one). I need to determine those bits and their
position and create new numbers from them. For example, consider this
four-bit number:
1100
from this number I want to extract two numbers:
1000 and 100
had the four-bit number been 0101 I would want to extract 100 and 1.
How should I do this? I wish I had some code to post but I don't...
|
by: Mart |
last post by:
What class does everyone out there use if they want to store a set of values
efficiently?
In java I use a HashSet, but there is no equivalent in C#.
Even worse, the lowest level interface to define the Add, Contains and
Remove methods is an IList, and we all should know that a set isn't a list.
ICollection only defines Count and CopyTo, which isn't useful at all. So
even if I want to write my own Set implementation, what interface...
| |
by: Anders Borum |
last post by:
Hello!
I have a class that needs to validate the input value, when a programmer
changes a specific property on a class. The input should only accept the
following pattern {1,n} (alpha-numeric with atleast one entry).
I'm a little resistant to implementing a regular expression validation,
because of the overhead involved (not because I can't :-). Obviously, it's
possible to implement the pattern validation using regular string ops ..
|
by: Anders Borum |
last post by:
Hello!
I was looking at marking objects with a changed state, once properties have
been changed. The reason behind this is, that I would like to enlist such
objects for processing in a transaction.
The example below illustrates a sample pattern, which is fine when exposing
simple value types.
However, when exposing reference types, it becomes really hard (if not
|
by: Phil Powell |
last post by:
// OBTAINED FROM http://www.javascripter.net/faq/settinga.htm
// NOTE THAT IF YOU SET days TO -1 THE COOKIE WILL BE SET TO YESTERDAY
AND THUS EXPIRE
function setCookie(name, value, days, docObj) {
var today = new Date();
var expire = new Date();
if (days == null || isNaN(days) || days == 0) days = 1;
if (days >= 1 || days < 0) expire.setTime(today.getTime() + 3600000 *
24 * days);
|
by: slrj |
last post by:
Can I use a local struct to store data in the "set" conatiner? If so, what is the correct method to do so?
Compiler: Sun Studio 10 on Unix (Sun Solaris)
#include<iostream>
#include<set>
using namespace std;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |