diff --git a/uppsrc/Geom/Ctrl/GeomCtrl.t b/uppsrc/Geom/Ctrl/GeomCtrl.t index e66faf773..702b31fa2 100644 --- a/uppsrc/Geom/Ctrl/GeomCtrl.t +++ b/uppsrc/Geom/Ctrl/GeomCtrl.t @@ -4,13 +4,13 @@ // pathCtrl.cpp T_("Close") -csCZ("Zavřít") +csCZ("Zav\305\231\303\255t") // pathedit.lay T_("&Initial segment:") -csCZ("&Začátek:") +csCZ("&Za\304\215\303\241tek:") T_("&Line segment:") csCZ("&Segment:") @@ -19,10 +19,10 @@ T_("&End segment:") csCZ("&Konec:") T_("&Relative width:") -csCZ("&Vztažná šířka:") +csCZ("&Vzta\305\276n\303\241 \305\241\303\255\305\231ka:") T_("&Cap style:") -csCZ("St&yl zlomu čáry:") +csCZ("St&yl zlomu \304\215\303\241ry:") T_("&Chamfer length:") csCZ("V&elikost zkosu:") @@ -34,83 +34,83 @@ T_("Cancel") csCZ("Storno") T_("&Grid:") -csCZ("&Mřížka:") +csCZ("&M\305\231\303\255\305\276ka:") T_("&Snap:") -csCZ("&Přichytit do mřížky:") +csCZ("&P\305\231ichytit do m\305\231\303\255\305\276ky:") T_("&Ruler") -csCZ("&Pravítko") +csCZ("&Prav\303\255tko") T_("&Axis") -csCZ("&Osa čáry") +csCZ("&Osa \304\215\303\241ry") // PlotterCtrl.cpp T_("Zoom in horz.") -csCZ("Zvětšit horiz.") +csCZ("Zv\304\233t\305\241it horiz.") T_("Zoom in horizontally") -csCZ("Zvětšit vodorovné měřítko") +csCZ("Zv\304\233t\305\241it vodorovn\303\251 m\304\233\305\231\303\255tko") T_("Zoom out horz.") -csCZ("Zmenšit horiz.") +csCZ("Zmen\305\241it horiz.") T_("Zoom out horizontally") -csCZ("Zmenšit vodorovné měřítko") +csCZ("Zmen\305\241it vodorovn\303\251 m\304\233\305\231\303\255tko") T_("Zoom full horz.") -csCZ("Celý rozsah horiz.") +csCZ("Cel\303\275 rozsah horiz.") T_("Display full x axis range in view") -csCZ("Zobrazit celý rozsah vodorovné osy") +csCZ("Zobrazit cel\303\275 rozsah vodorovn\303\251 osy") T_("Zoom in vert.") -csCZ("Zvětšit vert.") +csCZ("Zv\304\233t\305\241it vert.") T_("Zoom in vertically") -csCZ("Zvětšit svislé měřítko") +csCZ("Zv\304\233t\305\241it svisl\303\251 m\304\233\305\231\303\255tko") T_("Zoom out vert.") -csCZ("Zmenšit vert.") +csCZ("Zmen\305\241it vert.") T_("Zoom out vertically") -csCZ("Zmenšit svislé měřítko") +csCZ("Zmen\305\241it svisl\303\251 m\304\233\305\231\303\255tko") T_("Zoom full vert.") -csCZ("Celý rozsah vert.") +csCZ("Cel\303\275 rozsah vert.") T_("Display full y axis range in view") -csCZ("Zobrazit celý rozsah svislé osy") +csCZ("Zobrazit cel\303\275 rozsah svisl\303\251 osy") T_("Zoom out") -csCZ("Zmenšit") +csCZ("Zmen\305\241it") T_("Zoom out current view") -csCZ("Zmenšit měřítko zobrazení") +csCZ("Zmen\305\241it m\304\233\305\231\303\255tko zobrazen\303\255") T_("Zoom full") -csCZ("Skutečný rozměr") +csCZ("Zobrazit v\305\241e") T_("Zoom everything into view") -csCZ("Nastavit měřítko zobrazení podle velikosti okna") +csCZ("Nastavit m\304\233\305\231\303\255tko zobrazen\303\255 podle velikosti okna") T_("Zoom in") -csCZ("Zvětšit\tNum[+]") +csCZ("Zv\304\233t\305\241it\tNum[+]") T_("Zoom in current view (click to zoom in 2x, drag & drop to zoom in area)") -csCZ("Zvětšovat oblasti plochy (kliknutím zvětšíte 2x, tažením myši " - "zvětšíte zadanou oblast)") +csCZ("Zv\304\233t\305\241ovat oblasti plochy (kliknut\303\255m zv\304\233t\305\241\303\255te 2x, ta\305\276en\303\255m my\305\241i " + "zv\304\233t\305\241\303\255te zadanou oblast)") T_("Lock aspect ratio") -csCZ("Stejné měřítko os") +csCZ("Stejn\303\251 m\304\233\305\231\303\255tko os") T_("Keep temporarily x and y scale factors in sync") -csCZ("Dočasně udržovat stálé měřítko os x a y") +csCZ("Do\304\215asn\304\233 udr\305\276ovat st\303\241l\303\251 m\304\233\305\231\303\255tko os x a y") T_("Pan") csCZ("Posouvat") T_("Drag & drop view position") -csCZ("Posouvat zobrazenou oblast tažením myši") +csCZ("Posouvat zobrazenou oblast ta\305\276en\303\255m my\305\241i") diff --git a/uppsrc/Geom/Ctrl/PlotterCtrl.cpp b/uppsrc/Geom/Ctrl/PlotterCtrl.cpp index 4f6cf9be6..1e3428a9b 100644 --- a/uppsrc/Geom/Ctrl/PlotterCtrl.cpp +++ b/uppsrc/Geom/Ctrl/PlotterCtrl.cpp @@ -7,8 +7,8 @@ NAMESPACE_UPP #define IMAGEFILE #include -#define LLOG(x) // LOG(x) -#define LLOGBLOCK(x) // LOGBLOCK(x) +#define LLOG(x) RLOG(x) +#define LLOGBLOCK(x) RLOGBLOCK(x) PlotterCtrl::ViewPlot::ViewPlot(PlotterCtrl& ctrl, int extra_gap) : viewdraw(&ctrl) @@ -526,7 +526,7 @@ ImageDraw& PlotterCtrl::BeginBufferPaint() paint_buffer = Null; Size sz = max(GetSize(), Size(1, 1)); // paint_buffer = Image(max(GetSize(), Size(1, 1))); - LLOG("-> size = " << paint_buffer.GetSize()); + LLOG("-> size = " << sz); paint_draw = new ImageDraw(sz); paint_draw->DrawRect(sz, background); is_painting = true; @@ -559,53 +559,69 @@ void PlotterCtrl::PostRefresh() void PlotterCtrl::Paint(Draw& draw) { - LLOGBLOCK("PlotterCtrl::Paint"); - LLOG("PlotterCtrl::Paint @ " << GetSysTime()); - bool shown = IsDragging(); - DragHide(); - Rect clip = draw.GetPaintRect(); - if(is_painting) { -#ifdef PLATFORM_WIN32 - if(!paint_buffer.IsEmpty()) { - LLOG("-> blit paint_buffer"); - SystemDraw *sdraw = dynamic_cast(&draw); - if(!sdraw || !BitBlt(*sdraw, pan_offset, *paint_draw, paint_buffer.GetSize())) { - LLOG("-> blit error"); - } - } -#endif - } - else { - if(buffer_paint && !draw.Dots()) { - Size size = GetSize(); - if(paint_buffer.IsEmpty() || paint_buffer.GetSize() != size) { - LLOG("-> refresh paint buffer"); - Draw& idraw = BeginBufferPaint(); - Plotter plotter(idraw, scale, delta); - plotter.PathMap(&PathStyleMap::App()); - Plot(plotter); - EndBufferPaint(); - } - else { - LLOG("-> DrawImage paint_buffer"); - draw.DrawImage(pan_offset.x, pan_offset.y, paint_buffer); + int level = draw.GetCloffLevel(); + try { + LLOGBLOCK("PlotterCtrl::Paint"); + LLOG("PlotterCtrl::Paint @ " << GetSysTime() << ": level = " << level); + bool shown = IsDragging(); + DragHide(); + Rect clip = draw.GetPaintRect(); + if(is_painting) { + #ifdef PLATFORM_WIN32 + if(!paint_buffer.IsEmpty()) { + LLOG("-> blit paint_buffer"); + SystemDraw *sdraw = dynamic_cast(&draw); + if(!sdraw || !BitBlt(*sdraw, pan_offset, *paint_draw, paint_buffer.GetSize())) { + LLOG("-> blit error"); + } } + #endif } else { - LLOG("-> Plot (direct)"); - draw.DrawRect(clip, background); - Plotter plotter(draw, scale, delta + Pointf(pan_offset)); - plotter.PathMap(&PathStyleMap::App()); - Plot(plotter); - if(drag_drop) { - lock_drag_drop = true; - drag_drop->Plot(plotter); - lock_drag_drop = false; + if(buffer_paint && !draw.Dots()) { + Size size = GetSize(); + if(paint_buffer.IsEmpty() || paint_buffer.GetSize() != size) { + LLOG("-> refresh paint buffer"); + Draw& idraw = BeginBufferPaint(); + try { + Plotter plotter(idraw, scale, delta); + plotter.PathMap(&PathStyleMap::App()); + Plot(plotter); + } + catch(Exc e) { + RLOG("PlotterCtrl::Paint: exception in Plot: " << e); + } + catch(...) { + RLOG("PlotterCtrl::Paint: unknown exception in Plot"); + } + EndBufferPaint(); + } + else { + LLOG("-> DrawImage paint_buffer"); + draw.DrawImage(pan_offset.x, pan_offset.y, paint_buffer); + } + } + else { + LLOG("-> Plot (direct)"); + draw.DrawRect(clip, background); + Plotter plotter(draw, scale, delta + Pointf(pan_offset)); + plotter.PathMap(&PathStyleMap::App()); + Plot(plotter); + if(drag_drop) { + lock_drag_drop = true; + drag_drop->Plot(plotter); + lock_drag_drop = false; + } } } + if(shown) + DragShow(); } - if(shown) - DragShow(); + catch(Exc e) { + RLOG("PlotterCtrl::Paint: exception: " << e); + } + RLOG("//PlotterCtrl::Paint: level = " << draw.GetCloffLevel()); + ASSERT(level == draw.GetCloffLevel()); } /* diff --git a/uppsrc/Geom/Ctrl/PlotterCtrl.iml b/uppsrc/Geom/Ctrl/PlotterCtrl.iml index 22572bbf0..9951e6890 100644 --- a/uppsrc/Geom/Ctrl/PlotterCtrl.iml +++ b/uppsrc/Geom/Ctrl/PlotterCtrl.iml @@ -2,28 +2,53 @@ PREMULTIPLIED IMAGE_ID(view_zoom_in) IMAGE_ID(view_zoom_in_aniso) IMAGE_ID(view_zoom_out) +IMAGE_ID(view_zoom_full_old) IMAGE_ID(view_zoom_full) IMAGE_ID(view_zoom_horz_full) IMAGE_ID(view_zoom_vert_full) +IMAGE_ID(view_zoom_full_icon_old) IMAGE_ID(view_zoom_full_icon) IMAGE_ID(view_aspect_lock) IMAGE_ID(view_pan) IMAGE_ID(drag_horz) IMAGE_ID(drag_vert) +IMAGE_ID(info) +IMAGE_ID(meas) +IMAGE_ID(view_next) +IMAGE_ID(view_prev) +IMAGE_ID(zoom_lyr) +IMAGE_ID(zoom_sel) IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,237,88,217,110,3,33,12,164,15,169,242,146,40,255,255,179,116,87,21,21,235,216,158,177,77,87,61,226,21,10) -IMAGE_DATA(193,51,62,192,64,54,237,222,238,237,125,123,86,75,159,36,130,223,187,163,33,190,192,63,153,83,198,37,239,107,200,209) -IMAGE_DATA(121,227,29,97,196,88,87,26,195,163,253,101,243,27,58,109,206,197,218,88,114,88,51,185,150,128,219,12,28,203,245,236) -IMAGE_DATA(229,229,177,61,151,237,81,173,7,11,92,242,166,0,105,59,145,130,239,197,194,216,249,221,209,75,190,196,12,254,176,17) -IMAGE_DATA(217,8,93,107,69,255,213,252,7,134,221,32,218,252,207,185,23,54,202,193,142,146,79,192,134,90,115,128,175,47,143,97) -IMAGE_DATA(43,96,35,42,21,238,108,131,148,215,77,201,233,136,155,226,140,155,178,28,43,210,177,7,129,70,23,38,162,7,192,130) -IMAGE_DATA(141,175,218,203,203,126,83,146,190,10,59,182,114,98,84,79,44,105,39,43,17,190,134,179,248,114,44,123,34,207,125,52) -IMAGE_DATA(87,222,77,80,225,87,227,159,199,24,156,133,101,253,68,100,197,109,183,106,15,100,132,224,222,212,159,204,200,97,166,128) -IMAGE_DATA(81,209,106,216,76,161,177,197,101,232,47,219,148,184,128,167,0,81,66,149,10,102,5,249,64,19,234,76,216,77,157,16) -IMAGE_DATA(38,0,132,143,30,175,217,45,193,96,81,197,252,246,138,143,238,8,22,35,99,168,172,107,68,28,60,87,176,171,37,91) -IMAGE_DATA(64,222,66,91,122,249,105,197,98,157,0,204,119,43,110,203,23,235,199,226,32,95,90,46,178,143,56,94,220,104,252,27) -IMAGE_DATA(229,243,7,249,27,133,141,188,125,74,206,252,246,18,121,131,29,156,217,148,232,187,92,131,3,99,65,124,217,215,114,206) -IMAGE_DATA(240,201,156,85,126,212,231,89,252,73,55,231,216,60,190,228,160,53,210,190,35,249,105,252,136,13,15,135,108,152,250,71) -IMAGE_DATA(187,30,80,135,214,196,95,15,47,253,223,214,95,231,191,106,36,248,236,38,131,59,187,253,243,252,63,0,58,106,65,102) -IMAGE_END_DATA(448, 11) +IMAGE_DATA(120,156,237,90,91,114,219,48,12,212,79,58,249,73,38,147,19,235,104,190,25,43,59,162,2,130,120,44,8,90,109,90) +IMAGE_DATA(193,131,177,76,98,23,224,3,4,227,120,121,95,222,151,95,219,107,182,20,34,17,251,251,99,85,15,207,236,59,58,161) +IMAGE_DATA(157,227,142,38,163,207,106,47,158,13,107,43,130,34,56,216,223,232,248,106,159,52,231,108,109,52,105,214,140,175,165,131) +IMAGE_DATA(93,20,59,20,107,241,141,203,199,246,122,217,94,34,123,112,131,115,28,9,16,230,137,108,248,146,220,24,119,124,49,250) +IMAGE_DATA(57,158,219,84,124,229,136,36,66,145,52,233,63,59,254,106,131,38,136,52,255,116,236,137,68,105,120,132,241,4,56,196) +IMAGE_DATA(61,231,224,229,229,81,184,2,28,81,201,96,41,7,40,87,165,196,250,128,74,113,70,165,76,199,234,245,161,7,129,4) +IMAGE_DATA(103,20,209,3,96,66,226,139,124,227,114,175,148,160,175,68,198,102,78,140,236,137,197,121,70,37,130,151,236,52,60,111) +IMAGE_DATA(27,61,145,233,179,55,87,86,37,200,224,179,241,211,54,196,78,179,69,253,68,100,70,181,155,149,3,35,2,96,193,195) +IMAGE_DATA(32,122,234,29,184,117,93,31,186,7,178,233,246,188,250,60,119,204,237,118,35,216,29,71,85,225,168,62,31,88,142,241) +IMAGE_DATA(57,30,126,171,186,28,12,95,227,110,99,103,170,115,236,152,47,158,198,86,195,90,120,209,86,242,191,18,142,114,196,239) +IMAGE_DATA(142,91,240,111,142,179,177,39,235,202,252,183,186,118,216,175,49,114,61,214,64,224,105,57,90,188,84,157,133,117,235,98) +IMAGE_DATA(23,125,43,28,212,15,197,28,207,146,24,246,244,179,43,82,238,202,184,55,241,239,103,239,244,25,169,102,94,5,147,108) +IMAGE_DATA(71,170,14,90,105,148,254,151,109,74,76,131,46,64,111,64,153,114,134,138,231,195,155,80,99,194,222,196,9,65,2,240) +IMAGE_DATA(236,35,117,46,83,91,17,91,111,199,252,244,29,31,205,8,212,134,199,144,89,215,136,24,246,215,253,166,175,111,215,253) +IMAGE_DATA(230,186,223,168,107,118,244,139,190,21,14,234,135,98,142,103,73,12,123,250,217,21,41,119,101,28,86,189,102,203,104,53) +IMAGE_DATA(177,78,125,173,159,191,107,177,104,215,1,228,179,22,183,230,11,245,163,97,60,95,210,88,248,179,135,177,226,246,218,159) +IMAGE_DATA(40,248,87,117,105,209,179,198,183,215,190,27,85,177,220,158,126,6,190,151,141,226,37,30,21,35,113,11,28,16,94,137) +IMAGE_DATA(165,155,55,73,188,113,122,120,206,197,237,81,60,27,59,236,83,193,135,57,50,120,100,15,13,226,161,245,51,176,46,71) +IMAGE_DATA(135,255,88,94,27,88,163,188,252,93,253,255,118,255,43,173,12,220,248,108,229,193,157,173,255,251,248,207,185,38,172,133) +IMAGE_DATA(93,208,7,113,17,158,214,182,10,198,209,251,210,241,18,135,23,183,133,215,125,235,254,41,135,220,255,115,240,243,231,159) +IMAGE_DATA(203,232,30,200,238,193,121,121,240,36,249,220,94,39,75,33,154,225,176,62,207,226,61,131,67,178,71,219,104,95,132,199) +IMAGE_DATA(106,231,26,181,153,21,143,133,201,216,141,138,54,118,68,27,158,178,223,2,162,239,245,219,76,202,19,21,137,103,84,25) +IMAGE_DATA(79,243,77,115,84,135,86,228,217,18,188,41,101,7,49,225,80,44,25,142,29,175,114,0,155,162,88,28,172,31,209,134) +IMAGE_DATA(99,0,223,112,252,1,124,147,36,225,249,163,201,1,36,144,138,141,225,123,44,40,25,236,146,196,46,217,131,196,197,6) +IMAGE_DATA(254,55,56,42,19,146,119,8,239,37,62,136,133,255,182,85,176,127,123,50,127,227,251,132,139,227,101,14,124,254,188,196) +IMAGE_DATA(71,42,173,149,252,104,165,110,57,198,246,47,227,24,146,25,55,9,24,159,248,161,128,150,12,34,158,94,1,129,171,28) +IMAGE_DATA(132,167,254,17,188,116,29,53,252,55,252,220,167,22,127,93,124,42,117,65,121,12,138,255,110,126,36,78,37,126,97,118) +IMAGE_DATA(203,225,91,227,64,240,44,49,58,181,240,116,12,64,66,138,248,5,76,40,109,174,30,190,99,73,217,224,202,254,30,228) +IMAGE_DATA(248,142,107,50,199,8,190,114,168,157,103,29,6,139,176,25,133,205,28,194,83,255,16,190,140,31,6,20,47,197,161,29) +IMAGE_DATA(6,143,95,223,212,126,22,131,226,191,105,63,126,193,67,99,208,227,239,252,210,95,64,105,28,28,223,141,125,231,145,218) +IMAGE_DATA(217,252,119,254,234,51,245,227,29,6,28,63,114,24,112,191,203,117,24,28,28,90,223,111,154,36,191,69,0,0,0,0) +IMAGE_END_DATA(992, 19) diff --git a/uppsrc/Geom/Ctrl/pathedit.lay b/uppsrc/Geom/Ctrl/pathedit.lay index 0c86f5e29..c2ffac549 100644 --- a/uppsrc/Geom/Ctrl/pathedit.lay +++ b/uppsrc/Geom/Ctrl/pathedit.lay @@ -32,3 +32,4 @@ LAYOUT(PathStyleMapLayout, 484, 384) ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(90, 80).BottomPosZ(4, 22)) ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22)) END_LAYOUT + diff --git a/uppsrc/Geom/Draw/hrr.cpp b/uppsrc/Geom/Draw/hrr.cpp index 36200ec63..1e1d6903f 100644 --- a/uppsrc/Geom/Draw/hrr.cpp +++ b/uppsrc/Geom/Draw/hrr.cpp @@ -14,6 +14,349 @@ NAMESPACE_UPP #define LLOG(x) // LOG(x) +void CalcBitMasks(int bpp, const dword *in_cmasks, dword cmask[], int cshift24[], int cbits[]) +{ + static const dword cmasks16[] = { 0xF800, 0x07E0, 0x001F }; + static const dword cmasks32[] = { 0xFF0000, 0x00FF00, 0x0000FF }; + if(!in_cmasks) + in_cmasks = (bpp <= 16 ? cmasks16 : cmasks32); + else if((in_cmasks[0] | in_cmasks[1] | in_cmasks[2]) == 0) { + in_cmasks = (bpp <= 16 ? cmasks16 : cmasks32); + } + for(int i = 0; i < 3; i++) { + dword cm = in_cmasks[i]; + cmask[i] = cm; + int shift = 0; + if(!(cm & 0xFFFF0000)) { + cm <<= 16; + shift += 16; + } + if(!(cm & 0xFF000000)) { + cm <<= 8; + shift += 8; + } + if(!(cm & 0xF0000000)) { + cm <<= 4; + shift += 4; + } + if(!(cm & 0xC0000000)) { + cm <<= 2; + shift += 2; + } + if(!(cm & 0x80000000)) { + cm <<= 1; + shift += 1; + } + int width = 0; + dword mask = 0x80000000; + while((cm & mask) && width < 8) { + mask >>= 1; + width++; + } + cshift24[i] = shift; + cbits[i] = width; + } +} + +static void PixelZStreamInfo(Stream& stream, Size& size, Size& dot_size, Point& hotspot, int& raw_bpp, bool& mono) +{ + enum { VERSION = 1 }; + int version = VERSION; + stream.Magic(('P' << 24) | ('X' << 16) | ('A' << 8) | 'R'); + stream / version; + if(version > VERSION) { + stream.SetError(); + return; + } + Pack16(stream, raw_bpp, size.cx, size.cy, hotspot.x, hotspot.y); + stream % mono % dot_size; +} + +struct ZImageDirItem +{ + Size size; + Size dot_size; + Point hotspot; + int raw_bpp; + bool mono; + int alpha_bpp; + + void Serialize(Stream& stream) + { + PixelZStreamInfo(stream, size, dot_size, hotspot, raw_bpp, mono); + Pack16(stream, alpha_bpp); + } +}; + +class ZImageRaster : public StreamRaster { +public: + ZImageRaster() {} + + virtual bool Create(); + virtual Size GetSize(); + virtual Info GetInfo(); + virtual Line GetLine(int line); + virtual const RGBA *GetPalette(); + virtual const RasterFormat *GetFormat(); + +private: + ZImageDirItem item; + Vector palette; + dword cmask[3]; + int cshift24[3]; + int cbits[3]; + int pixel_row_bytes; + int alpha_row_bytes; + int pixel_block_size; + int alpha_block_size; + int line_number; + String block; + int block_offset; + Vector pixel; + Vector alpha; + Vector rgba_palette; + RasterFormat format; +}; + +bool ZImageRaster::Create() +{ + static const unsigned MAGIC_TAG = 'Z' * 0x1000000 + 'I' * 0x10000 + 'M' * 0x100 + 'G'; + static const int VERSION = 1; + + format.SetRGBA(); + + Stream& stream = GetStream(); + + stream.Magic(MAGIC_TAG); + if(stream.IsError()) + return false; + int version = VERSION; + stream / version; + if(version > VERSION) { + LLOG("ImageZStreamInfo: version error: " << version); + stream.SetError(); + return false; + } + Array dir; + int count = 0; + stream % count; + enum { MAX_COUNT = 1000 }; + if(count < 0 || count > MAX_COUNT) { + LLOG("ImageZStreamInfo: image count error: " << count); + stream.SetError(); + return false; + } + if(stream.IsLoading()) + dir.SetCount(count); + for(int i = 0; i < count && !stream.IsError(); i++) + stream % dir[i]; + if(stream.IsError() || dir.IsEmpty()) + return false; + item = dir[0]; + + Buffer offsets(dir.GetCount() + 1); + for(int i = 0; i <= dir.GetCount(); i++) + stream % offsets[i]; + int64 base = stream.GetPos(); + stream.Seek(base + offsets[0]); + + if(item.size.cx <= 0 || item.size.cy <= 0) + return false; + + version = VERSION; + stream / version; + if(version > VERSION) { + LLOG("PixelZStreamData -> version error: " << version); + stream.SetError(); + return false; + } + if(item.raw_bpp) { + int bpp = (item.raw_bpp < 0 ? 24 : item.raw_bpp); + if(bpp <= 8) { + stream % palette; + rgba_palette.SetCount(1 << bpp, RGBAZero()); + for(int i = 0; i < palette.GetCount() && i < rgba_palette.GetCount(); i++) + rgba_palette[i] = (RGBA)palette[i]; + } + else if(bpp == 16 || bpp == 32) { + stream % cmask[0] % cmask[1] % cmask[2]; + CalcBitMasks(bpp, cmask, cmask, cshift24, cbits); + } + pixel_block_size = 0; + Pack16(stream, pixel_block_size); + if(pixel_block_size <= 0) { + LLOG("ZImageRaster::Create -> block size error: " << pixel_block_size); + stream.SetError(); + return false; + } + pixel_row_bytes = ((item.size.cx * bpp + 31) >> 5) << 2; + pixel.SetCount(item.size.cy * pixel_row_bytes, 0); + for(int i = 0; i < item.size.cy;) { + int e = min(item.size.cy, i + pixel_block_size); + String part; + stream % part; + String dpart = ZDecompress(part); + if(dpart.IsVoid()) { + LLOG("PixelZStreamData -> decompress error @ row " << i << " (source size = " << part.GetLength() << ")"); + stream.SetError(); + return false; + } + int x = 0; + memcpy(pixel.GetIter(i * pixel_row_bytes), dpart, min(pixel_row_bytes * (e - i), dpart.GetLength())); + i = e; + } + } + + version = VERSION; + stream / version; + if(version > VERSION) { + LLOG("PixelZStreamData -> version error: " << version); + stream.SetError(); + return false; + } +/* + if(item.alpha_bpp) { + alpha_row_bytes = ((item.size.cx + 31) >> 5) << 2; + alpha.SetCount(item.size.cy * alpha_row_bytes, 0); + Vector mask_palette; + stream % mask_palette; + Pack16(stream, alpha_block_size); + if(alpha_block_size <= 0) { + LLOG("PixelZStreamData -> block size error: " << alpha_block_size); + stream.SetError(); + return false; + } + + for(int i = 0; i < item.size.cy;) { + int e = min(item.size.cy, i + alpha_block_size); + String part; + stream % part; + String dpart = ZDecompress(part); + if(dpart.IsVoid()) { + LLOG("PixelZStreamData -> decompress error @ row " << i << " (source size = " << part.GetLength() << ")"); + stream.SetError(); + return false; + } + memcpy(alpha.GetIter(i * alpha_row_bytes), dpart, min((e - i) * alpha_row_bytes, dpart.GetLength())); + i = e; + } + } +*/ + return true; +} + +Size ZImageRaster::GetSize() +{ + return item.size; +} + +Raster::Info ZImageRaster::GetInfo() +{ + Info info; + if(item.raw_bpp > 0 && item.raw_bpp <= 8) + info.colors = 1 << item.raw_bpp; + info.bpp = (item.raw_bpp < 0 ? 24 : item.raw_bpp); + info.dots = item.dot_size; + return info; +} + +Raster::Line ZImageRaster::GetLine(int ln) +{ + RGBA *line = new RGBA[item.size.cx]; +/* + if(item.alpha_bpp) { + const byte *ao = alpha.GetIter(ln * alpha_row_bytes); + byte active = *ao++; + byte avail = 8; + RGBA *out = line; + for(int width = item.size.cx; --width >= 0; out++) { + if(!avail) { + active = *ao++; + avail = 8; + } + --avail; + out->a = (active & 0x80 ? 0 : 255); + active <<= 1; + } + } + else */ { + RGBA bg; + bg.r = bg.g = bg.b = 0; + bg.a = 255; + Fill(line, bg, item.size.cx); + } + if(item.raw_bpp) { + const byte *po = pixel.GetIter(ln * pixel_row_bytes); + RGBA *out = line; + if(item.raw_bpp == -3) { + for(int width = item.size.cx; --width >= 0; out++, po += 3) { + out->b = po[0]; + out->g = po[1]; + out->r = po[2]; + } + } + else if(item.raw_bpp <= 8) { + byte shift = item.raw_bpp; + byte per_byte = 8 / item.raw_bpp; + byte active = 0; + byte avail = 0; + RGBA zero = RGBAZero(); + for(int width = item.size.cx; --width >= 0; out++) { + if(!avail) { + active = *po++; + avail = per_byte; + } + --avail; + int index = (active << shift) >> 8; + active <<= shift; + RGBA value = (index < rgba_palette.GetCount() ? rgba_palette[index] : zero); + out->r = value.r; + out->g = value.g; + out->b = value.b; + } + } + else if(item.raw_bpp == 16 || item.raw_bpp == 24 || item.raw_bpp == 32) { + byte bshift = cshift24[2]; + byte bmask = (-256 >> cbits[2]) & 0xFF; + byte gshift = cshift24[1]; + byte gmask = (-256 >> cbits[1]) & 0xFF; + byte rshift = cshift24[0]; + byte rmask = (-256 >> cbits[0]) & 0xFF; + + if(item.raw_bpp == 16) { + for(int width = item.size.cx; --width >= 0; out++, po += 2) { + uint16 w = Peek16le(po); + out->r = byte((w << rshift) >> 24) & rmask; + out->g = byte((w << gshift) >> 24) & gmask; + out->b = byte((w << bshift) >> 24) & bmask; + } + } + else { + for(int width = item.size.cx; --width >= 0; out++, po += 4) { + uint32 w = Peek32le(po); + out->r = byte((w << rshift) >> 24) & rmask; + out->g = byte((w << gshift) >> 24) & gmask; + out->b = byte((w << bshift) >> 24) & bmask; + } + } + } + else { + RLOG("ZImageRaster::GetLine: invalid pixel BPP = " << item.raw_bpp); + } + } + return Raster::Line(line, true); +} + +const RGBA * ZImageRaster::GetPalette() +{ + return NULL; +} + +const RasterFormat * ZImageRaster::GetFormat() +{ + return &format; +} + void RasterCopy(RasterEncoder& dest, Raster& src, const Rect& src_rc) { dest.Start(src_rc.Size()); @@ -123,6 +466,7 @@ One HRRInfo::GetDecoder() const case METHOD_JPG: return new JPGRaster; case METHOD_GIF: return new GIFRaster; case METHOD_PNG: return new PNGRaster; + case METHOD_ZIM: return new ZImageRaster; default: return 0; } } @@ -730,6 +1074,7 @@ One HRR::StdCreateDecoder(const HRRInfo& info) case HRRInfo::METHOD_GIF: return new GIFRaster; case HRRInfo::METHOD_PNG: return new PNGRaster; case HRRInfo::METHOD_JPG: return new JPGRaster; + case HRRInfo::METHOD_ZIM: return new ZImageRaster; // case HRRInfo::METHOD_BMP: return new BMPRaster; } return NULL; diff --git a/uppsrc/Oracle/Oci8.cpp b/uppsrc/Oracle/Oci8.cpp index 064ee3285..31d82736f 100644 --- a/uppsrc/Oracle/Oci8.cpp +++ b/uppsrc/Oracle/Oci8.cpp @@ -223,7 +223,7 @@ void OCI8Connection::Item::DynaFlush() { if(dyna_full) { dyna_full = false; Value v; - if(ind == 0) { + if(ind[0] == 0) { if(dyna_len > dyna_width) dyna_width = dyna_len; const byte *p = Data();