U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » [SOLVED] accessing pixels in JPEG created from memory buffer
Re: accessing pixels in JPEG created from memory buffer [message #21421 is a reply to message #21419] Tue, 19 May 2009 14:00 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3461
Registered: August 2008
Senior Veteran
Hello qwerty

The mrjt sample is perfect.

I inclose you a little change for you to see the rows and cols handling:

// Load raw image into memory
FileIn fin(IMAGE_FILE_PATH);
if (!fin.IsOpen()) 
	{ Exclamation("Unable to open file"); return; }
String raw = fin.Get((dword)fin.GetSize());

// Convert String to uncompressed Image
Image img = StreamRaster::LoadStringAny(raw);
// If you know the image format you could also use:
// Image img = JPGRaster().LoadString(raw);
if (IsNull(img)) 
	{ Exclamation("Unknown/Bad image format"); return; }

// If you need to modify the image use an ImageBuffer
ImageBuffer ib(img);
for (int row = 0; row < ib.GetHeight(); ++row) {
	RGBA *rowData = ib[row];
	for(int col = 0; col < ib.GetWidth(); col++) {
		rowData[col].red   = 255-rowData[col].red; // Inverting the colors
		rowData[col].green = 255-rowData[col].green;
		rowData[col].blue  = 255-rowData[col].blue;
	}
}
img = ib;


Here we are inverting the colors so for example red are converted to 255-red as the maximum value of a color is 255.

Best regards
Koldo


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Optimal ctrl refresh
Next Topic: Draw package and console app error
Goto Forum:
  


Current Time: Mon Sep 21 00:34:29 GMT+2 2026

Total time taken to generate the page: 0.00972 seconds