Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2005-09-17 00:17:09 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2005-09-17 00:17:09 +0400
commit0804d66f7932279539bbf1026990b26491ee59e2 (patch)
tree38c00c77e2e292e1ccde46d1b0e9a4b783070712 /source/blender/img/intern
parent7c29e6d551127453154d4a97698d77992f2180f7 (diff)
- Imagepaint code cleanup:
- Move UVTEXTTOOL variables into global Gip struct (like Gvp for vertex paint). This will probably be moved into SpaceImage later, so it is saved with the .blend file. - Disable tool drawing. a better solution needs to be found. - Panel button layout is still the same, this will change. - Removed the NAN_TPT define, it has no use anymore.
Diffstat (limited to 'source/blender/img/intern')
-rw-r--r--source/blender/img/intern/IMG_Api.cpp28
-rw-r--r--source/blender/img/intern/IMG_CanvasRGBA32.cpp60
-rw-r--r--source/blender/img/intern/IMG_CanvasRGBA32.h12
3 files changed, 48 insertions, 52 deletions
diff --git a/source/blender/img/intern/IMG_Api.cpp b/source/blender/img/intern/IMG_Api.cpp
index d0f49fc798b..c57e5e7c5a1 100644
--- a/source/blender/img/intern/IMG_Api.cpp
+++ b/source/blender/img/intern/IMG_Api.cpp
@@ -37,12 +37,12 @@
#include <config.h>
#endif
-IMG_BrushPtr IMG_BrushCreate(unsigned int w, unsigned int h, float r, float g, float b, float a)
+IMG_BrushPtr IMG_BrushCreate(unsigned int w, unsigned int h, float *rgba)
{
IMG_BrushPtr brush = 0;
try {
- IMG_ColorRGB c (r, g, b);
- brush = new IMG_BrushRGBA32 (w, h, c, a);
+ IMG_ColorRGB c (rgba[0], rgba[1], rgba[2]);
+ brush = new IMG_BrushRGBA32 (w, h, c, rgba[3]);
}
catch (...) {
brush = 0;
@@ -50,7 +50,6 @@ IMG_BrushPtr IMG_BrushCreate(unsigned int w, unsigned int h, float r, float g, f
return brush;
}
-
void IMG_BrushDispose(IMG_BrushPtr brush)
{
if (brush) {
@@ -75,8 +74,6 @@ void IMG_BrushSetInnerRaduisRatio(IMG_BrushPtr brush,float aspect)
}
}
-
-
IMG_CanvasPtr IMG_CanvasCreate(unsigned int w, unsigned int h)
{
IMG_CanvasPtr canvas = 0;
@@ -89,7 +86,6 @@ IMG_CanvasPtr IMG_CanvasCreate(unsigned int w, unsigned int h)
return canvas;
}
-
IMG_CanvasPtr IMG_CanvasCreateFromPtr(void* imagePtr, unsigned int w, unsigned int h, size_t rowBytes)
{
IMG_CanvasPtr canvas = 0;
@@ -139,28 +135,28 @@ void IMG_CanvasDrawLineUV(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart
((IMG_CanvasRGBA32*)canvas)->blendPixmap(uStart, vStart, uEnd, vEnd, *((IMG_BrushRGBA32*)brush));
}
-void IMG_CanvasDrawLineUVEX(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd,char mode)
+void IMG_CanvasDrawLineUVEX(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd, int torus)
{
if (!(canvas && brush)) return;
- ((IMG_CanvasRGBA32*)canvas)->blendPixmap(uStart, vStart, uEnd, vEnd, *((IMG_BrushRGBA32*)brush),mode);
+ ((IMG_CanvasRGBA32*)canvas)->blendPixmap(uStart, vStart, uEnd, vEnd, *((IMG_BrushRGBA32*)brush), torus);
}
-void IMG_CanvasSoftenAt(IMG_CanvasPtr canvas,float u, float v, unsigned int size,float alpha, float aspect,char mode)
+void IMG_CanvasSoftenAt(IMG_CanvasPtr canvas,float u, float v, unsigned int size,float alpha, float aspect, int torus)
{
- ((IMG_CanvasRGBA32*)canvas)->SoftenAt(u,v,(TUns32)size,alpha,aspect,mode);
+ ((IMG_CanvasRGBA32*)canvas)->SoftenAt(u, v, (TUns32)size, alpha, aspect, torus);
}
-void IMG_CanvasFill(IMG_CanvasPtr canvas,float red, float green, float blue, float alpha)
+void IMG_CanvasFill(IMG_CanvasPtr canvas, float *rgba)
{
- IMG_ColorRGB c (red, green, blue);
+ IMG_ColorRGB c (rgba[0], rgba[1], rgba[2]);
IMG_Rect R (0, 0, ((IMG_CanvasRGBA32*)canvas)->getWidth(),
((IMG_CanvasRGBA32*)canvas)->getHeight()); // Bounds of this pixmap
- ((IMG_CanvasRGBA32*)canvas)->fillRect(R,c);
+ ((IMG_CanvasRGBA32*)canvas)->fillRect(R, c);
}
-void IMG_CanvasSmear(IMG_CanvasPtr canvas,float uStart, float vStart, float uEnd, float vEnd, unsigned int size, float alpha, float aspect,char mode)
+void IMG_CanvasSmear(IMG_CanvasPtr canvas,float uStart, float vStart, float uEnd, float vEnd, unsigned int size, float alpha, float aspect, int torus)
{
- ((IMG_CanvasRGBA32*)canvas)->Smear(uStart,vStart,uEnd,vEnd,size,alpha,aspect,mode);
+ ((IMG_CanvasRGBA32*)canvas)->Smear(uStart, vStart, uEnd, vEnd, size, alpha, aspect, torus);
}
diff --git a/source/blender/img/intern/IMG_CanvasRGBA32.cpp b/source/blender/img/intern/IMG_CanvasRGBA32.cpp
index 72e4aaf8fd1..6070160d489 100644
--- a/source/blender/img/intern/IMG_CanvasRGBA32.cpp
+++ b/source/blender/img/intern/IMG_CanvasRGBA32.cpp
@@ -48,17 +48,17 @@ IMG_CanvasRGBA32::IMG_CanvasRGBA32(void* image, TUns32 width, TUns32 height, TUn
void IMG_CanvasRGBA32::blendPixmap(
TUns32 xStart, TUns32 yStart, TUns32 xEnd, TUns32 yEnd,
- const IMG_PixmapRGBA32& pixmap,char mode)
+ const IMG_PixmapRGBA32& pixmap, bool torus)
{
// Determine visibility of the line
IMG_Line l (xStart, yStart, xEnd, yEnd); // Line used for blending
IMG_Rect bnds (0, 0, m_width, m_height); // Bounds of this pixmap
TVisibility v = bnds.getVisibility(l);
- if (mode == 'c'){
- if (v == kNotVisible) return;
- if (v == kPartiallyVisible) {
- bnds.clip(l);
- }
+ if (!torus) {
+ if (v == kNotVisible)
+ return;
+ if (v == kPartiallyVisible)
+ bnds.clip(l);
}
float numSteps = (((float)l.getLength()) / ((float)pixmap.getWidth() / 4));
@@ -68,12 +68,10 @@ void IMG_CanvasRGBA32::blendPixmap(
TInt32 x, y;
for (TUns32 s = 0; s < numSteps; s++) {
l.getPoint(step, x, y);
- if (mode == 'c') {
- IMG_PixmapRGBA32::blendPixmap((TUns32)x, (TUns32)y, pixmap);
- }
- else {
- if (mode == 't') IMG_PixmapRGBA32::blendPixmapTorus((TUns32)x, (TUns32)y, pixmap);
- }
+ if (torus)
+ IMG_PixmapRGBA32::blendPixmapTorus((TUns32)x, (TUns32)y, pixmap);
+ else
+ IMG_PixmapRGBA32::blendPixmap((TUns32)x, (TUns32)y, pixmap);
step += stepSize;
}
}
@@ -81,16 +79,16 @@ void IMG_CanvasRGBA32::blendPixmap(
void IMG_CanvasRGBA32::blendPixmap(
float uStart, float vStart, float uEnd, float vEnd,
- const IMG_PixmapRGBA32& pixmap, char mode)
+ const IMG_PixmapRGBA32& pixmap, bool torus)
{
TUns32 xStart, yStart, xEnd, yEnd;
getPixelAddress(uStart, vStart, xStart, yStart);
getPixelAddress(uEnd, vEnd, xEnd, yEnd);
- blendPixmap(xStart, yStart, xEnd, yEnd, pixmap,mode);
+ blendPixmap(xStart, yStart, xEnd, yEnd, pixmap, torus);
}
-void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, float aspect,char mode)
+void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, float aspect, bool torus)
{
IMG_BrushRGBA32* brush = 0;
int flag=0;
@@ -116,7 +114,7 @@ void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, floa
getPixelAddress(u, v, x, y);
xx = x - size/2;
yy = y - size/2;
- if(mode == 't') flag = 1;
+ if(torus) flag = 1;
/* now modify brush */
for (int i= 0 ; i<(int)size;i++){
@@ -125,11 +123,11 @@ void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, floa
float sR,sG,sB,sA;
float cR,cG,cB=0.0;
-if(mode == 't')
- IMG_PixmapRGBA32::getRGBAatTorus(xx+i,yy+j ,&cR,&cG,&cB,0);
+ if (torus)
+ IMG_PixmapRGBA32::getRGBAatTorus(xx+i,yy+j ,&cR,&cG,&cB,0);
+ else
+ IMG_PixmapRGBA32::getRGBAat(xx+i,yy+j ,&cR,&cG,&cB,0);
-else
- IMG_PixmapRGBA32::getRGBAat(xx+i,yy+j ,&cR,&cG,&cB,0);
int ccount = 1;
/*
cR += 7.0*cR;
@@ -160,10 +158,11 @@ add_if_in(xx+i-1,yy+j-1,cR,cG,cB,ccount,flag);
}
/* apply */
-if(mode == 't')
- IMG_PixmapRGBA32::blendPixmapTorus(x, y, *brush);
-else
- IMG_PixmapRGBA32::blendPixmap(x, y, *brush);
+ if (torus)
+ IMG_PixmapRGBA32::blendPixmapTorus(x, y, *brush);
+ else
+ IMG_PixmapRGBA32::blendPixmap(x, y, *brush);
+
/* done clean up */
if (brush) {
delete ((IMG_BrushRGBA32*)brush);
@@ -261,24 +260,25 @@ IMG_BrushRGBA32* IMG_CanvasRGBA32::LiftBrush(float u, float v, TUns32 size, floa
return(brush);
}
-void IMG_CanvasRGBA32::Smear(float uStart, float vStart, float uEnd, float vEnd, TUns32 size, float alpha, float aspect,char mode)
+void IMG_CanvasRGBA32::Smear(float uStart, float vStart, float uEnd, float vEnd, TUns32 size, float alpha, float aspect, bool torus)
{
IMG_BrushRGBA32* brush = NULL;
float du,dv;
du = uEnd - uStart;
dv = vEnd - vStart;
+
try {
- brush = LiftBrush(uStart-du,vStart-dv,size,alpha,aspect,1);
+ brush = LiftBrush(uStart-du, vStart-dv, size, alpha, aspect, 1);
}
catch (...) {
/* no brush , no fun ! */
return;
}
- if (brush){
- blendPixmap(uStart,vStart,uEnd,vEnd,*brush,mode);
- delete(brush);
- }
+ if (brush) {
+ blendPixmap(uStart, vStart, uEnd, vEnd, *brush, torus);
+ delete(brush);
+ }
}
void IMG_CanvasRGBA32::CloneAt(IMG_CanvasRGBA32* other,float u,float v,float cu,float cv,TUns32 size,float alpha,float aspect)
diff --git a/source/blender/img/intern/IMG_CanvasRGBA32.h b/source/blender/img/intern/IMG_CanvasRGBA32.h
index e7eaaa86280..4c60e3522cc 100644
--- a/source/blender/img/intern/IMG_CanvasRGBA32.h
+++ b/source/blender/img/intern/IMG_CanvasRGBA32.h
@@ -46,12 +46,12 @@
class IMG_CanvasRGBA32 : public IMG_PixmapRGBA32 {
public:
- int add_if_in(int x, int y,float &R,float &G,float &B, int &count, short flags);
- void Smear(float uStart, float vStart, float uEnd, float vEnd ,TUns32 size, float alpha, float aspect,char mode);
+ int add_if_in(int x, int y, float &R, float &G, float &B, int &count, short flags);
+ void Smear(float uStart, float vStart, float uEnd, float vEnd ,TUns32 size, float alpha, float aspect, bool torus=false);
IMG_BrushRGBA32* LiftBrush(float u, float v, TUns32 size, float alpha, float aspect, short flags );
IMG_BrushRGBA32* LiftBrush(TUns32 x, TUns32 y, TUns32 size, float alpha, float aspect, short flags);
- void SoftenAt(float u,float v,TUns32 size,float alpha,float aspect,char mode);
- void CloneAt(IMG_CanvasRGBA32* other,float u,float v,float cu,float cv,TUns32 size,float alpha,float aspect);
+ void SoftenAt(float u, float v, TUns32 size, float alpha, float aspect, bool torus=false);
+ void CloneAt(IMG_CanvasRGBA32* other, float u, float v, float cu, float cv, TUns32 size, float alpha, float aspect);
/**
* Constructor.
* @throw <IMG_MemPtr::Size> when an invalid width and/or height is passed.
@@ -82,7 +82,7 @@ public:
* @param y y-coordinate of the center location of the image.
* @param pixmap the pixmap to blend
*/
- virtual void blendPixmap(TUns32 xStart, TUns32 yStart, TUns32 xEnd, TUns32 yEnd, const IMG_PixmapRGBA32& pixmap,char mode = 'c');
+ virtual void blendPixmap(TUns32 xStart, TUns32 yStart, TUns32 xEnd, TUns32 yEnd, const IMG_PixmapRGBA32& pixmap, bool torus=false);
/**
* Blends a pixmap into this pixmap over a line in (u,v) coordinates.
@@ -94,7 +94,7 @@ public:
* @param v v-coordinate of the center location of the image.
* @param pixmap the pixmap to blend
*/
- virtual void blendPixmap(float uStart, float vStart, float uEnd, float vEnd, const IMG_PixmapRGBA32& pixmap,char mode = 'c');
+ virtual void blendPixmap(float uStart, float vStart, float uEnd, float vEnd, const IMG_PixmapRGBA32& pixmap, bool torus=false);
};