-
Notifications
You must be signed in to change notification settings - Fork 0
/
dCopyPhotoAndSMS.deltaj
94 lines (73 loc) · 2.91 KB
/
dCopyPhotoAndSMS.deltaj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
delta dCopyPhotoAndSMS {
//package lancs.mobilemedia.core.ui.controller
modifies lancs.mobilemedia.core.ui.controller.CopyPhoto {
adds import lancs.mobilemedia.core.ui.screens.PhotoViewScreen;
modifies finishCopyCommand(AbstractController controller, AddPhotoToAlbum copyPhotoToAlbum) {
//copy from sms
if (( (PhotoViewScreen) controller.getCurrentScreen() ).isFromSMS()) {
copyPhotoToAlbum.setImage(( (PhotoViewScreen) controller.getCurrentScreen() ).getImage());
}
original(controller, copyPhotoToAlbum);
}
}
modifies lancs.mobilemedia.core.ui.controller.SaveCopiedPhoto {
adds import javax.microedition.lcdui.Image;
modifies addImageDataToAlbum(AbstractController controller, String photoname, String albumname) {
Image img = ((AddPhotoToAlbum) controller.getCurrentScreen()).getImage();
if (img != null) {
controller.getAlbumData().addImageData(photoname, img, albumname);
}
else {
original(controller, photoname, albumname);
}
}
}
//package lancs.mobilemedia.core.ui.datamodel
modifies lancs.mobilemedia.core.ui.datamodel.AlbumData {
adds public void addImageData(String photoname, Image img, String albumname)
throws InvalidImageDataException, PersistenceMechanismException {
imageAccessor.addImageData(photoname,img,albumname);
}
}
modifies lancs.mobilemedia.core.ui.datamodel.ImageAccessor {
adds public void addImageData(String photoname, Image imgdata, String albumname) throws InvalidImageDataException, PersistenceMechanismException {
try {
imageRS = RecordStore.openRecordStore(ALBUM_LABEL + albumname, true);
imageInfoRS = RecordStore.openRecordStore(INFO_LABEL + albumname, true);
int rid;
int rid2;
ImageUtil converter = new ImageUtil();
byte[] data1 = getByteFromImage(imgdata);
rid = imageRS.addRecord(data1, 0, data1.length);
ImageData ii = new ImageData(rid, ImageAccessor.ALBUM_LABEL
+ albumname, photoname);
rid2 = imageInfoRS.getNextRecordID();
ii.setRecordId(rid2);
data1 = converter.getBytesFromImageInfo(ii);
imageInfoRS.addRecord(data1, 0, data1.length);
imageRS.closeRecordStore();
imageInfoRS.closeRecordStore();
} catch (RecordStoreException e) {
throw new PersistenceMechanismException();
}
}
adds public byte[] getByteFromImage(Image img){
int w = img.getWidth();
int h = img.getHeight();
/* int data_int[] = new int[ w * h ];
img.getRGB( data_int, 0, w, 0, 0, w, h );
byte[] data_byte = new byte[ w * h * 3 ];
for ( int i = 0; i < w * h; ++i )
{
int color = data_int[ i ];
int offset = i * 3;
data_byte[ offset ] = ( byte ) ( ( color & 0xff0000 ) >> 16 );
data_byte[ offset +
1 ] = ( byte ) ( ( color & 0xff00 ) >> 8 );
data_byte[ offset + 2 ] = ( byte ) ( ( color & 0xff ) );
}
return data_byte;*/
return null;
}
}
}