Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Some simple way to convert Image into 1bpp raw data in memory?
Some simple way to convert Image into 1bpp raw data in memory? [message #27055] Wed, 23 June 2010 14:59 Go to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
I thought it will be easy to do this, but can't figure it out.
Image RGBAimage;
BMPEncoder bmpencoder(1);
bmpencoder.SaveFile("image.bmp", RGBAimage);
FileIn in("image.bmp");
One<StreamRaster> raster = StreamRaster::OpenAny(in);
//... then something like:
const byte * data = raster->GetLine( y ).GetRawData();

this does convert RGBA image into 1bpp bmp, load it back from disk and then it's easy to read raw data trough const byte * data pointer.

Now I'm trying to cut out that unnecessary save/load on disk sequence, and I can't find any simple way.

So far it looks to me like these are only options:
1) create my own RawEncoder : StreamRasterEncoder which would do the 1bpp conversion in same way as BMPEncoder does it
2) use RasterFormat to do the conversion line by line (in such case I would like too see what's the simplest way to initialize it for RGBA (B&W only, no AA) -> 1bpp conversion.
3) use BMPEncoder on some memory stream and read it back from that stream like I'm doing it now from file?
4) give up and simply do my own conversion code (it's trivial as the source image is B&W only anyway, it's not true RGBA pic)

any upp guru to tell me which solution is nice and simple to do? Smile

[Updated on: Wed, 23 June 2010 14:59]

Report message to a moderator

Re: Some simple way to convert Image into 1bpp raw data in memory? [message #27065 is a reply to message #27055] Thu, 24 June 2010 08:43 Go to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
So far I settled down with saving BMP file into string stream, then reading it back from string as StreamRaster. It not optimal, but the BMP has only around 60kB anyway and it was 5-6 lines of code.
Previous Topic: Image: Rescale proportional propose:
Next Topic: Image from URL
Goto Forum:
  


Current Time: Thu Mar 28 15:09:11 CET 2024

Total time taken to generate the page: 0.01261 seconds