473,486 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

From j2mephone to c# ==> Wrong palette of BMP Image (if gray ok)

Hi,
i sent image byte via bt from j2me phone to c# application,
after i have to create image using this code:

....
byte[] pixels
....

Bitmap bmp = new Bitmap(160, 120, PixelFormat.Format8bppIndexed);

BitmapData d = bmp.LockBits(new Rectangle(0, 0, 160, 120),
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
// image data is pixel
Marshal.Copy(pixels, 0, d.Scan0, pixels.Length);

bmp.UnlockBits(d);

// Grey-Scale Palette works
/*
ColorPalette cp = bmp.Palette;
for (int i = 0; i < cp.Entries.Length; i++)
cp.Entries[i] = Color.FromArgb(i, i, i);
bmp.Palette = cp;
*/

this.pictureBox1.Image = bmp;

bmp.Save("C:\\img.bmp");

-----------------

The image that i save has all wrong color...
If i use other than Format8bppIndexed i have smaller size image
repeated on 160x120 pixel with color wrong too

Can someone helps me?

(sorry for bad english)

Thanks

May 22 '06 #1
0 1233

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

Similar topics

2
15048
by: Tommie Nygren | last post by:
For different reasons I am reading an array of bytes from a file in my ..jar-file and from this I want to create a PNG image using Image.createImage(myArray, 0 , myArray.length). I had a...
5
2503
by: Benjamin Esham | last post by:
Hello all, I have a very wide image that I want positioned in the extreme top left of the page. If the browser window is too narrow to contain the whole thing, that's fine-- the image should...
2
11119
by: James dean | last post by:
Do i have to create an index pallette. How do i do that?. Or, Can i not just make an ordinary 8pp pixel format without this indexed problem...... *** Sent via Developersdex...
2
5615
by: RicercatoreSbadato | last post by:
I'm trying to use this code but something goes wrong. Any idea? BitmapData oldData = img.LockBits(new Rectangle(0,0,width,height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); ...
8
2450
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the...
2
2630
by: Piotrekk | last post by:
Hi I am trying to get color palette of image and change it: Image tmpImg = pictureBox1.Image; // Here tmpImg.Palette sometimes has 0 entries and sometimes has some entries However when i...
3
2369
by: krishnasamy | last post by:
Hi, I have writing the code for change the Palette color of the Bitmap. But I didn't get any different between given image and result image. Here I given my code, Bitmap *bmp=new...
20
6964
by: Joe Duchtel | last post by:
Hello - I have the following code to get a bitmap from the clipboard and to save it to a *.png file ... Dim lData As IDataObject = Clipboard.GetDataObject() If...
1
1473
by: jj | last post by:
The following creates a copy of an image. It worked fine in Visual Studio 2005, but after installing Visual Studio 2008 then opening the solution as a ..net 2.0 project, I get an error on the...
0
7100
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,...
1
6842
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...
0
7330
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
5434
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,...
1
4865
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...
0
3070
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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 ...
0
262
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...

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.