summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 695303a)
raw | patch | inline | side by side (parent: 695303a)
author | kiirala <kiirala@users.sourceforge.net> | |
Tue, 12 Jun 2007 19:04:36 +0000 (19:04 +0000) | ||
committer | kiirala <kiirala@users.sourceforge.net> | |
Tue, 12 Jun 2007 19:04:36 +0000 (19:04 +0000) |
src/display/Makefile_insert | patch | blob | history | |
src/display/nr-filter-getalpha.cpp | [new file with mode: 0644] | patch | blob |
src/display/nr-filter-getalpha.h | [new file with mode: 0644] | patch | blob |
src/display/nr-filter-slot.cpp | patch | blob | history |
index a4d7470017c9c99bf7214d2405dc4b821cd1ccf0..462da04c58f05d31a05fc7960a373e6fbbd1a697 100644 (file)
display/nr-filter-offset.h \
display/nr-filter-slot.cpp \
display/nr-filter-slot.h \
+ display/nr-filter-getalpha.cpp \
+ display/nr-filter-getalpha.h \
display/nr-filter-types.h \
display/pixblock-scaler.cpp \
display/pixblock-scaler.h \
diff --git a/src/display/nr-filter-getalpha.cpp b/src/display/nr-filter-getalpha.cpp
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Functions for extracting alpha channel from NRPixBlocks.
+ *
+ * Author:
+ * Niko Kiirala <niko@kiirala.com>
+ *
+ * Copyright (C) 2007 Niko Kiirala
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-getalpha.h"
+#include "libnr/nr-blit.h"
+#include "libnr/nr-pixblock.h"
+
+namespace NR {
+
+NRPixBlock *filter_get_alpha(NRPixBlock *src)
+{
+ NRPixBlock *dst = new NRPixBlock;
+ nr_pixblock_setup_fast(dst, NR_PIXBLOCK_MODE_R8G8B8A8P,
+ src->area.x0, src->area.y0,
+ src->area.x1, src->area.y1, false);
+ nr_blit_pixblock_pixblock(dst, src);
+
+ unsigned char *data = NR_PIXBLOCK_PX(dst);
+ int end = dst->rs * (dst->area.y1 - dst->area.y0);
+ for (int i = 0 ; i < end ; i += 4) {
+ data[i + 0] = 0;
+ data[i + 1] = 0;
+ data[i + 2] = 0;
+ }
+ dst->empty = false;
+
+ return dst;
+}
+
+} // namespace NR
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/display/nr-filter-getalpha.h b/src/display/nr-filter-getalpha.h
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __NR_FILTER_GETALPHA_H__
+#define __NR_FILTER_GETALPHA_H__
+
+/*
+ * Functions for extracting alpha channel from NRPixBlocks.
+ *
+ * Author:
+ * Niko Kiirala <niko@kiirala.com>
+ *
+ * Copyright (C) 2007 Niko Kiirala
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "libnr/nr-pixblock.h"
+
+namespace NR {
+
+NRPixBlock *filter_get_alpha(NRPixBlock *src);
+
+}
+
+#endif /* __NR_FILTER_GETALPHA_H__ */
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 32fc00f9950ddecbd326164fc94cba9fdcec6d85..3cdc20ede9cd554f4a4a66cfc62baaf56e052815 100644 (file)
#include "display/nr-arena-item.h"
#include "display/nr-filter-types.h"
#include "display/nr-filter-slot.h"
+#include "display/nr-filter-getalpha.h"
#include "libnr/nr-pixblock.h"
#include "libnr/nr-blit.h"
|| slot_nr == NR_FILTER_STROKEPAINT))
{
/* If needed, fetch background */
- if (slot_nr == NR_FILTER_BACKGROUNDIMAGE
- || slot_nr == NR_FILTER_BACKGROUNDALPHA)
- {
+ if (slot_nr == NR_FILTER_BACKGROUNDIMAGE) {
NRPixBlock *pb;
pb = nr_arena_item_get_background(_arena_item);
if (pb) {
- NRPixBlock *bg = new NRPixBlock;
- nr_pixblock_setup_fast(bg, pb->mode,
- pb->area.x0, pb->area.y0,
- pb->area.x1, pb->area.y1, true);
- bool empty = pb->empty;
pb->empty = false;
- nr_blit_pixblock_pixblock(bg, pb);
- pb->empty = empty;
- bg->empty = false;
- this->set(NR_FILTER_BACKGROUNDIMAGE, bg);
+ this->set(NR_FILTER_BACKGROUNDIMAGE, pb);
} else {
NRPixBlock *source = this->get(NR_FILTER_SOURCEGRAPHIC);
pb = new NRPixBlock();
pb->empty = FALSE;
this->set(NR_FILTER_BACKGROUNDIMAGE, pb);
}
- }
- /* If only a alpha channel is needed, strip it from full image */
- if (slot_nr == NR_FILTER_SOURCEALPHA) {
- // TODO
- }
- if (slot_nr == NR_FILTER_BACKGROUNDALPHA) {
+ } else if (slot_nr == NR_FILTER_SOURCEALPHA) {
+ /* If only a alpha channel is needed, strip it from full image */
+ NRPixBlock *src = get(NR_FILTER_SOURCEGRAPHIC);
+ NRPixBlock *sa = filter_get_alpha(src);
+ set(NR_FILTER_SOURCEALPHA, sa);
+ } else if (slot_nr == NR_FILTER_BACKGROUNDALPHA) {
+ NRPixBlock *src = get(NR_FILTER_BACKGROUNDIMAGE);
+ NRPixBlock *ba = filter_get_alpha(src);
+ set(NR_FILTER_BACKGROUNDALPHA, ba);
+ } else if (slot_nr == NR_FILTER_FILLPAINT) {
+ /* When a paint is needed, fetch it from arena item */
// TODO
- }
- /* When a paint is needed, fetch it from arena item */
- if (slot_nr == NR_FILTER_FILLPAINT) {
- // TODO
- }
- if (slot_nr == NR_FILTER_STROKEPAINT) {
+ } else if (slot_nr == NR_FILTER_STROKEPAINT) {
// TODO
}
}
int seek = _slot_count;
do {
seek--;
- } while (_slot[seek] == NULL);
-
+ } while (!_slot[seek] && _slot_number[seek] == NR_FILTER_SLOT_NOT_SET);
+
return seek + 1;
}
int seek = _slot_count;
do {
seek--;
- } while (_slot[seek] == NULL && seek > 0);
+ } while (_slot_number[seek] == NR_FILTER_SLOT_NOT_SET && seek >= 0);
/* If there is no space for more slots, create more space */
if (seek == _slot_count - 1) {
NRPixBlock **new_slot = new NRPixBlock*[_slot_count * 2];