473,810 Members | 3,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can you create a 1Bpp png

I have read that you can create a 1bpp png image but has anyone any idea
how to do it?......

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
3 5224
Hi James,

Don't you post this question two times before?

Nicholas Paldino answer to it tomorrow.

I can only give you a sample:

// Windows Application - project
// 2 x Button
// 1 x PictureBox (anchor it L-T-R-B for resizing)
// 1 x SaveFileDialog
// add these methods as a buttons Click handlers!

private void button1_Click(o bject sender, System.EventArg s e) {
// here bmp with 1bpp is created
Bitmap bmp=new Bitmap(pictureB ox1.ClientSize. Width
, pictureBox1.Cli entSize.Height
, System.Drawing. Imaging.PixelFo rmat.Format1bpp Indexed);
if( pictureBox1.Ima ge!=null ) {
Image img=pictureBox1 .Image;
pictureBox1.Ima ge=null;
img.Dispose();
}
pictureBox1.Ima ge=bmp;
}

private void button2_Click(o bject sender, System.EventArg s e) {
Image img=pictureBox1 .Image;
if( img!=null ) {
saveFileDialog1 .DefaultExt="pn g";
if( saveFileDialog1 .ShowDialog(thi s)==DialogResul t.OK ) {
try {
// here this bmp is saved as a PNG 1bpp image
img.Save(saveFi leDialog1.FileN ame
, System.Drawing. Imaging.ImageFo rmat.Png);
}
catch(Exception ex) {
MessageBox.Show ("Save error: "+ex.Messag e);
}
}
}
else {
MessageBox.Show ("There's no image to save!");
}
}

Regards

Marcin
I have read that you can create a 1bpp png image but has anyone any idea
how to do it?......

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Are u sure that does not save the file as an 8bpp png and doesn't save
it properly either. I saved my 1bpp image as a png just like you did
here......but it did not save it correctly. Maybe the way u are using
the picturebox is how u are doing it.....is it?....how come when i have
my 1bpp bitmap say called OneBppBitmap... then i do:
OneBppBitmap.sa ve("filename.pn g",ImageFormat. Png)......it doesn't do it
right?......

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Hi James,

My image browser (InfranView) displays the saved PNG file info as a:
width x height x 1bpp, but Window explorer informs about 8bpp.
But i'm not sure about details of PNG format, so it can depend
on entries in 8bpp palette.

I'm pretty sure that my pictureBox has nothig to do with a PNG
saving.

Regards

Marcin

PS: Maybe PNG supports only 8bpp & 24bpp (in standard or in .NET
libraries).
Are u sure that does not save the file as an 8bpp png and doesn't save
it properly either. I saved my 1bpp image as a png just like you did
here......but it did not save it correctly. Maybe the way u are using
the picturebox is how u are doing it.....is it?....how come when i have
my 1bpp bitmap say called OneBppBitmap... then i do:
OneBppBitmap.sa ve("filename.pn g",ImageFormat. Png)......it doesn't do it
right?......

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4

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

Similar topics

7
8876
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
2
2784
by: James Dean | last post by:
Could anybody tell me the most efficient way to set the bits in a 1Bpp class. I am reading in byte lines of an image. The byte array tells me what what bits are turned on or off.....i do bit masking to get the colour....i can just convert the whole Line byte array to a bitarray.....Also i have trouble about how to set the pointer to point at a bit instead of a byte.....when i lock the the bits i want the pointer pointing at a bit not a...
2
3708
by: James Dean | last post by:
I create a bitmap like this. The width and height are got from the compressed file i am reading. The width and height are in pixels.....1bpp bitmap = new Bitmap(Width,Height,PixelFormat.Format24bppRgb); i have a bitmapdata class and then lock the bits like this. bitmapData = bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
0
1329
by: James Dean | last post by:
I save a 1bpp bitmap as a 1bpp png......i save this 1bpp png in a memorystream.....problem is i want to convert this back to a 1bpp bitmap but it always saves as a 32bpp bitmap....i need the 1bpp png format.....if i saved the 1bpp bitmap in a the memory stream as a bitmap there would be no problem... Bitmap oneBppBmp = new Bitmap(pageSizeInPixels.width,pageSizeInPixels.Height,PixelFormat.1bppIn dexed); MemoryStream pngStream = new...
4
4420
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create shortcut to my program/utility (2) Entry in Windows' Start --> Program Menu. Actually in my VB.Net solution I have two projects (1) MYPROGRAM (2) MYPROGRAM_INSTALLER. MYPROGRAM is a "Windows Application". MYPROGRAM_INSTALLER is a "SetUp Wizard"...
10
8827
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung other things, can create views based on existing tables and a table of column name equivalents. If I accidently introduce a column name equivalent that is the same as another column, I end up with a CREATE VIEW SQL statement that is in error, if...
37
3317
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html PEP: XXX Title: The create statement
18
2727
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html In this post, I'm especially soliciting review of Carl Banks's point (now discussed under Open Issues) which asks if it would be better to have the create statement translated into:
0
2618
by: news.microsoft.com | last post by:
Hi guys, This text looks long and complicate but it is not, and I really really need some help here. For the last 24hs I'm trying to resolve this issue (last night I dreamed
0
9722
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, 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...
0
10644
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
10379
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
10393
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
10124
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...
1
7664
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
6882
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();...
0
5550
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...
3
3015
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.