mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
32
tutorial/Image05/main.cpp
Normal file
32
tutorial/Image05/main.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <plugin/jpg/jpg.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
FileSel fs;
|
||||
fs.Type("Image file", "*.bmp;*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.gif");
|
||||
if(!fs.ExecuteOpen("Choose the image file to convert"))
|
||||
return;
|
||||
String fn = ~fs;
|
||||
JPGEncoder jpg(20);
|
||||
FileIn in(fn);
|
||||
One<StreamRaster> raster = StreamRaster::OpenAny(in);
|
||||
if(!raster) {
|
||||
Exclamation("Invalid input");
|
||||
return;
|
||||
}
|
||||
FileOut out(fn + ".out.png");
|
||||
jpg.SetStream(out);
|
||||
jpg.Create(raster->GetSize());
|
||||
for(int i = 0; i < raster->GetHeight(); i++) {
|
||||
RasterLine l = raster->GetLine(i);
|
||||
Buffer<RGBA> out(raster->GetWidth());
|
||||
for(int j = 0; j < raster->GetWidth(); j++) {
|
||||
out[j].g = out[j].b = out[j].r = l[j].g;
|
||||
out[j].a = 255;
|
||||
}
|
||||
jpg.WriteLine(out);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue